Hi,

I don´t think using requests objects into templates is a good idea, use request 
object in the view so you source the template context with whatever you need.

HTH

El 17/09/2013, a las 20:50, J Y <[email protected]> escribió:

> I am building a search form that provides a drop down list, and then on the 
> search results, I am redisplaying the search form, but with the search 
> parameters already pre-selected, so this is what I attempted to do:
> 
> <select name="system">
>     {% for item in object_list %}
>         <option value="{{ item.id }}" {% if item.id == request.GET.system %} 
> selected="selected" {% endif %}>
>             {{ item.name }}
>         </option>
>     {% endfor %}
> </select>
> 
> Unfortunately, this did not work.  When I did some testing, I realized that 
> item.id is giving back an int, while request.GET.system is giving back a 
> string.  If I used the view to change the GET value to an int in the context, 
> then the comparison works.
> 
> What I am wondering is, is this expected behavior?  Does the request object 
> always return a string, and that I am better off writing my own custom tag to 
> convert request objects into int for comparison?  What is the best practice 
> to employ here?  I am fairly new to django and could use some pointers.
> 
> Thanks,
> 
> Jack
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to