Show creation date if publication date is not available
def is_published(self):
return self.status == 1
def is_published(self):
return self.status == 1
+ def publication_date(self):
+ if self.published_at is None:
+ return self.created_at
+ else:
+ return self.published_at
+
@receiver(pre_save, sender=Note)
def note_pre_save(sender, instance, **kwargs):
if instance.pk is None:
@receiver(pre_save, sender=Note)
def note_pre_save(sender, instance, **kwargs):
if instance.pk is None:
<h2><a href="{{ note.get_absolute_url }}"{% if note.is_draft %} class="text-muted"{% endif %}>{{ note.title }}</a></h2>
{% if note.is_draft %}<p class="fw-bold">Status: Draft</p>{% endif %}
<div>{{ note.content|markdown|safe }}</div>
<h2><a href="{{ note.get_absolute_url }}"{% if note.is_draft %} class="text-muted"{% endif %}>{{ note.title }}</a></h2>
{% if note.is_draft %}<p class="fw-bold">Status: Draft</p>{% endif %}
<div>{{ note.content|markdown|safe }}</div>
- <p class="publication-date">Published on {{ note.created_at|date:"Y-m-d, H:i" }}</p>
+ <p class="publication-date">Published on {{ note.publication_date|date:"Y-m-d, H:i" }}</p>
</article>
\ No newline at end of file
</article>
\ No newline at end of file