Sunday, September 23, 2018

what's the difference between TemplateView, ListView and DetailView ?

My answer was not fully on the topic. You shouldn't do what you want to do but if there's a real need for that...

You can add context by overriding get_context() method.

(context = super().get_context(); context['type'] = list; return context).

{% if type == list %}
<p>This is a list</p>
{% elif type == template %}
<p>This is just a template</p>
...

Or just e.g. context['list'] == True
And then:
{% if list %}
<p>This is a list</p>
{% if template %}
<p>This is just a template</p>
...

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f63c6291-6f71-41b1-ac4b-6eb37ff5e5eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment