diff --git a/website/blog/migrations/0003_blogpostpage_date.py b/website/blog/migrations/0003_blogpostpage_date.py new file mode 100644 index 0000000..0308d49 --- /dev/null +++ b/website/blog/migrations/0003_blogpostpage_date.py @@ -0,0 +1,19 @@ +# Generated by Django 4.0.5 on 2022-06-19 19:57 + +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("blog", "0002_blogposttag_taggedblog_blogpostpage_tags"), + ] + + operations = [ + migrations.AddField( + model_name="blogpostpage", + name="date", + field=models.DateField(default=django.utils.timezone.now), + ), + ] diff --git a/website/blog/models.py b/website/blog/models.py index 96fe202..1be8a3c 100644 --- a/website/blog/models.py +++ b/website/blog/models.py @@ -2,6 +2,7 @@ from typing import Any from django.db import models from django.http.request import HttpRequest +from django.utils import timezone from modelcluster.contrib.taggit import ClusterTaggableManager from modelcluster.fields import ParentalKey from taggit.models import ItemBase, TagBase @@ -47,7 +48,10 @@ class BlogPostPage(BaseContentMixin, BasePage): # type: ignore[misc] parent_page_types = [BlogListPage] tags = ClusterTaggableManager(through=TaggedBlog, blank=True) + date = models.DateField(default=timezone.now) content_panels = ( - BasePage.content_panels + BaseContentMixin.content_panels + [FieldPanel("tags")] + BasePage.content_panels + + BaseContentMixin.content_panels + + [FieldPanel("date"), FieldPanel("tags")] ) diff --git a/website/common/templates/common/hero.html b/website/common/templates/common/hero.html index c9af2d1..a69bbba 100644 --- a/website/common/templates/common/hero.html +++ b/website/common/templates/common/hero.html @@ -15,7 +15,9 @@