Sergey
Sergey

Reputation: 167

how to get the value of a single object?

I'm doing a presentation of the sample model (Footer.objects.all()) and send the result to the template. deduce the template through the cycle for:

{% for entrie in copyright_obj%} 
     {{entrie.copyright}} 
{% endfor%} 

The resulting data are displayed on the screen

but if I do so sample Footer.objects.all()[0], I get a message on the screen error

Exception Type: TypeError 
Exception Value: 
'Footer' object is not iterable 

please tell me how can I print the data in this case?

Upvotes: 0

Views: 63

Answers (1)

Raydel Miranda
Raydel Miranda

Reputation: 14360

The statement

Footer.objects.all()[0]

don't have any problem.

The thing is you're using the same template and you're trying to iterate over a single Footer objet.

Upvotes: 2

Related Questions