I filter a subject from database:
subject = Subject.objects.filter(id=1)
I tried to call it form template:
{{ subject.name|safe }}
It return empty value. Do I need to loop the object? It just return a single records:
>>> subject[0].name
u'010-01 INTERNATIONAL : Organizations'
But when I put {{ subject[0].name|safe }}, it return no value too.
Try:
{{subject.0.name}}If you’re only getting one object from the database, you should typically use
You could also use the get_object_or_404 shortcut.