Created basic templates to display news items, categories and tags.

dev
Calum Andrew Morrell 2025-11-09 21:43:02 +00:00
parent 284bddd0d8
commit 7538220e9a
5 changed files with 103 additions and 0 deletions

View File

@ -0,0 +1,21 @@
{% extends 'base.html' %}
{% block content %}
<main>
{% if object_list %}
<h3>Category List</h3>
<hr>
<ul>
{% for category in object_list %}
<li>
<a href="{{ category.get_absolute_url }}">{{ category.title }}</a>
<!-- {% if category.introduction %} -->
<!-- <hr> -->
<!-- <p>{{ category.introduction }}</p> -->
<!-- {% endif %} -->
</li>
{% endfor %}
</ul>
{% endif %}
</main>
{% endblock %}

View File

@ -0,0 +1,3 @@
{% for tag in newsitem.tags.all %}
<a href="{{ tag.get_absolute_url }}">{{ tag }}</a>{% if tag != newsitem.tags.last %},{% endif %}
{% endfor %}

View File

@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% block content %}
<article>
<h3>{{ newsitem.title }}</h3>
<p>{{ newsitem.created_at | date:'jS \o\f F, Y' }}</p>
<hr>
<div>
{{ newsitem.body_as_markdown|safe }}
</div>
<hr>
<div>
<span>Posted in the <a href="{% url 'news:list_category' category=newsitem.category.slug %}">{{ newsitem.category }}</a> category</span>
<span>{% include 'news/includes/display_tags.html' %}</span>
</div>
</article>
{% endblock %}

View File

@ -0,0 +1,45 @@
{% extends 'base.html' %}
{% block content %}
<main>
{% if object_list %}
{% if category %}
<h3>{{ category }} News</h3>
<!-- {% if category.introduction %} -->
<!-- <div> -->
<!-- <p>{{ category.introduction }}</p> -->
<!-- </div> -->
<!-- {% endif %} -->
{% elif tag %}
<h3>News for tag: {{ tag }}</h3>
{% else %}
<h3>Recent News</h3>
{% endif %}
<hr>
<div>
{% for news in object_list %}
<div>
<a href="{{ news.get_absolute_url }}">{{ news.title }}</a>
<hr >
<div>
<span>
<a href="{% url 'news:list_category' category=news.category.slug %}">{{ news.category }} </a>
&bull; {{ news.created | date:'jS \o\f F, Y' }}
</span>
<span>{% include 'news/includes/display_tags.html' %}</span>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div>
<h3>Oops!</h3>
<h5>It looks like there is no news for that {% if category %}category{% elif tag %}tag{% endif %} yet.</h5>
<p>(sorry not sorry)</p>
</div>
{% endif %}
{% if page_obj.has_previous or page_obj.has_next %}
{% include 'pagination.html' %}
{% endif %}
</main>
{% endblock %}

View File

@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% block content %}
<main>
{% if object_list %}
<h3>List of Tags</h3>
<hr>
<ul>
{% for tag in object_list %}
<li>
<a href="{{ tag.get_absolute_url }}">{{ tag }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
</main>
{% endblock %}