The Course App — Part 2

Rendering things conditionally

Want more?

This lesson for enrolled students only. Join the course to unlock it!

You can see the code changes implemented in this lecture below.

If you have purchased the course in a different platform, you still have access to the code changes per lecture here on Teclado. The lecture video and lecture notes remain locked.
Join course for $15

Modified files

templates/app/home.html
--- 
+++ 
@@ -4,9 +4,14 @@
   <h1>Articles</h1>

   <a href="{% url 'create_article' %}">Create article</a>
-  <ul>
-    {% for article in articles %}
-      <li><a href="{% url 'update_article' article.id %}">{{ article.title }}</a> with {{ article.word_count }} words.</li>
-    {% endfor %}
-  </ul>
+
+  {% if articles %}
+    <ul>
+      {% for article in articles %}
+        <li><a href="{% url 'update_article' article.id %}">{{ article.title }}</a> with {{ article.word_count }} words.</li>
+      {% endfor %}
+    </ul>
+  {% else %}
+    <p>You have no articles yet.</p>
+  {% endif %}
 {% endblock content %}