Answer the question
In order to leave comments, you need to log in
How to display the model on all pages?
I have a model that I display in the header through for, but I don't like what I write in each function.
I tried using templatetags
Categorie.objects.all().order_by('id')
@register.simple_tag(takes_context=True)
def header_categories(context):
return Categorie.objects.all().order_by('id')
{%header_categories%}
{% for cat in header_categories %}
cat.text
{% endfor %}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question