The context needs to be a dictionary.

Something like this would work:
context = {
    ‘items’: Model.objects.all()
}

Then in the template:
{% for item in items %}
  <h1>{{ item.text }}</h1>
{% endfor %}

Here ‘text’ is the property on the database model you want to display.


Regards,


Andréas

> 12 dec. 2020 kl. 17:11 skrev Peter T <[email protected]>:
> 
> Example:
> context = (database model)
> 
> def index(request):
>      render(index.html, context)
> 
> HTML Template:
> 
> {% for i in context %}
>      <h1>{ database.text }</h1>
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/035bd359-0df5-4d1c-b7b7-f4e08584c288n%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CF2E6908-6A88-4B33-8E1F-D6FF2BED81F5%40hypercode.se.

Reply via email to