More article features and markdown editor

Removing duplication from our form templates

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

New files

templates/app/layouts/base_form.html
{% extends "app/base.html" %}

{% block content %}
{% endblock content %}

{% block page_js %}
<script>
const contentMarkdown = new EasyMDE({
  element: document.getElementById("id_content"),
  spellChecker: false,
  status: false,
  toolbar: false,
  forceSync: true
});
</script>
{% endblock page_js %}

Modified files

templates/app/article_update.html
--- 
+++ 
@@ -1,4 +1,4 @@
-{% extends "app/base.html" %}
+{% extends "app/layouts/base_form.html" %}

 {% block content %}
   <h1>Edit Article</h1>
@@ -12,16 +12,4 @@

   <a href="{% url 'home' %}">Back to list</a>
   <a href="{% url 'delete_article' article.id %}">Delete article</a>
-{% endblock content %}
-
-{% block page_js %}
-<script>
-const contentMarkdown = new EasyMDE({
-  element: document.getElementById("id_content"),
-  spellChecker: false,
-  status: false,
-  toolbar: false,
-  forceSync: true
-});
-</script>
-{% endblock page_js %}+{% endblock content %}
templates/app/article_create.html
--- 
+++ 
@@ -1,4 +1,4 @@
-{% extends "app/base.html" %}
+{% extends "app/layouts/base_form.html" %}

 {% block content %}
   <h1>Create Article</h1>
@@ -9,16 +9,4 @@
   </form>

   <a href="{% url 'home' %}">Back to list</a>
-{% endblock content %}
-
-{% block page_js %}
-<script>
-const contentMarkdown = new EasyMDE({
-  element: document.getElementById("id_content"),
-  spellChecker: false,
-  status: false,
-  toolbar: false,
-  forceSync: true
-});
-</script>
-{% endblock page_js %}+{% endblock content %}