Skip to content

Commit

Permalink
19 - Using Conditions in a Template
Browse files Browse the repository at this point in the history
  • Loading branch information
codingforentrepreneurs committed Jul 5, 2018
1 parent 8a7b45b commit 0b11a44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def contact_view(request, *args, **kwargs):
def about_view(request, *args, **kwargs):
my_context = {
"my_text": "This is about us",
"this_is_true": True,
"my_number": 123,
"my_list": [1313, 4231, 312, "Abc"]

Expand Down
12 changes: 10 additions & 2 deletions src/templates/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ <h1>About</h1>
</ul>

<ul>
{% for my_sub_item in my_list %}
<li>{{ forloop.counter }} - {{ my_sub_item }}</li>
{% for abc in my_list %}
{% if abc == 312 %}
<li>{{ forloop.counter }} - {{ abc|add:22 }}</li>
{% elif abc == "Abc" %}
<li>This is not the network</li>
{% else %}
<li>{{ forloop.counter }} - {{ abc }}</li>
{% endif %}


{% endfor %}
</ul>

Expand Down

0 comments on commit 0b11a44

Please sign in to comment.