Question

please help bring in the template property of the object.

usually for a set of objects I deduce properties of the loop through the "FOR":

{% for entrie in news_all %}
    <br /><strong>{{ entrie.title }}</strong>
{% endfor %}

but now I passed to the template is only one object, so no need to use a loop

Was it helpful?

Solution

Just get the object field using dot notation: {{ entrie.title }}

(assuming entrie is passed in the template context).

Though, if you are passing a queryset in the context, the result of objects.filter(), for example, that contains only one object, you can still use the dot notation: first get the first element from a queryset, then an attribute/field:

{{ entries.0.title }}

See some examples here.

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top