Hi, thanks - that provides some perspective.

So if I omitted the .get() and .values() i will have to loop over the 
queryset and then each dict, doing something like:

{% for q in info %}
          {% for k, v in q.items %}
                   {{ k }} {{ v}}
          {% empty %}
                   no data
          {% endfor %}
{%endfor%}
?




Den onsdag den 18. september 2013 00.02.21 UTC+2 skrev Daniel Roseman:
>
> Without the get(), you get a queryset, which is an iterable of all 
> elements that match the query - in effect, a list of dicts. Even though 
> only one record matches, you still get a queryset containing a single dict. 
> So in order to use that in your template, you'd have to add an outer loop 
> iterating through each item in the queryset, while the inner loop iterates 
> over the elements in each dict.
>
> Reverse relations work with a model instance. But you don't have one of 
> those - you've got a dict, because you used .values(). If you dropped that 
> call, you'd have an instance which you could use the backwards relation on, 
> but you wouldn't be able to iterate over the fields with .items(). Note 
> that most of the time you don't need to do that, so mostly you would use 
> the instance rather than calling .values().
>
> -- 
> DR.
>
>

-- 
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