Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3842600
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:49:01+00:00 2026-05-19T15:49:01+00:00

I am trying to pass in url parameters to a django template like this…

  • 0

I am trying to pass in url parameters to a django template like this…

response = render_to_string('persistConTemplate.html', request.GET)

This the calling line from my views.py file. persistConTemplate.html is the name of my template and request.GET is the dictionary that contains the url parameters.

In the template I try to use one of the parameters like this…

{% for item in (numItems) %}

  item {{item}}

{% endfor %}

numItems is one of the url parameters that I am sending in my request like this…

http:/someDomain/persistentConTest.html/?numItems=12

When I try the for loop above, I get an output like this….

image 1 image 2

I am expecting and would like to see the word image printed 12 times…

image 1 image 2 image 3 image 4 image 5 image 6 image 7 image 8 image 9 image 10 image 11 image 12

Can anyone please tell me what I am going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:49:02+00:00Added an answer on May 19, 2026 at 3:49 pm

    Yes, the place for this is in the view.

    I feel like the above example won’t work — you can’t iterate over an integer.

    numItems = request.GET.get('numItems')
    
    if numItems:
       numItems = range(1, int(numItems)+1)
    
    return direct_to_template(request, "mytemplate.html", {'numItems': numItems})
    
    
    {% for item in numItems %}
     {{ item }}
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass parameters to a URL which looks like this: http://www.foobar.com/foo?imageurl=
I am trying to pass two parameters in my navigate URL to request them
I'm trying to pass parameter from python page to another through the URL,this parameter(key
I'm trying to get php to automatically pass the session ID via url, even
What is wrong with this code? I am trying to pass parameters to a
I'm trying to pass a userId (string) in the URL which will be passed
I am trying pass class as value in hashmap. I need to get the
im trying to pass two parameters to a function, i being an int value
Im trying to pass some variables from the URL to the PHP script. Now
I'm trying to pass an array of string parameters to a C# ASP.NET web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.