How to understand below html code?

20 views
Skip to first unread message

Utpal Brahma

unread,
Mar 27, 2018, 12:11:22 AM3/27/18
to Django users
I am in tutorial 3 of Django.But i am stuck in understanding the below code.Please heLP me!!!


{% if latest_question_list %}
<ul>
{% for question in latest_question_list %}
<li><a href="/polls/{{ question.id }}/">{{ question.question_text }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}

Lachlan Musicman

unread,
Mar 27, 2018, 12:18:18 AM3/27/18
to django...@googlegroups.com
Utpal, it's not pure HTML. It's got some templating in there as well - Jinja2 I think is the default.

Regardless, it reads like Python:

if the list exists, open an unnumbered list
for every question in the list, create a dot point with the list question. The list question will be a html a link back to the question. End for
end list
else
"no list"
end if


Cheers
L.




------
"The antidote to apocalypticism is apocalyptic civics. Apocalyptic civics is the insistence that we cannot ignore the truth, nor should we panic about it. It is a shared consciousness that our institutions have failed and our ecosystem is collapsing, yet we are still here — and we are creative agents who can shape our destinies. Apocalyptic civics is the conviction that the only way out is through, and the only way through is together. "

Greg Bloom @greggish https://twitter.com/greggish/status/873177525903609857


--
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...@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/160290fc-a15a-43f4-b1f1-7cdcb6d5c9b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jani Tiainen

unread,
Mar 27, 2018, 6:07:29 AM3/27/18
to django...@googlegroups.com
Hi.

That's actually Django template which uses Django templating language. It's not Jinja2 as suggested in other post.

What it does is well explained in that other post though.

--
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...@googlegroups.com.

Daniel Hepper

unread,
Mar 27, 2018, 7:25:30 AM3/27/18
to django...@googlegroups.com
Hi,

I just want to chime in and clarify that while Django does indeed support Jinja2, it is not the default template language.

Django comes with its own template language, which is used in the tutorial, the documentation and probably most articles related to Django.


However, Lachian's interpretation of the template is correct.

It is worth noting that Jinja2 is actually modeled after the Django template language, so it is easy to confuse the two on a first glance.

Cheers, 
Daniel

Utpal Brahma

unread,
Mar 27, 2018, 7:29:25 AM3/27/18
to django...@googlegroups.com
Thanks a lot ---

Lachlan Musicman

Daniel Hepper

and

Daniel Hepper    

Your answer meant a lot to me.Thank you very much guys.


--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/shmTr4Vegoc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages