summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan DeMasi <jon.demasi@colorado.edu>2020-03-02 16:32:38 -0700
committerJonathan DeMasi <jon.demasi@colorado.edu>2020-03-02 16:32:38 -0700
commita5512c4b7429c1c8d8d9d8fec83fafcbb4f2255a (patch)
tree523ea34e7bf81469bc6d4d150e78dc931a75ecbb
parent16d9e16b204718fd476e738b8cc906fb7e919b56 (diff)
downloadjthanio-a5512c4b7429c1c8d8d9d8fec83fafcbb4f2255a.tar
jthanio-a5512c4b7429c1c8d8d9d8fec83fafcbb4f2255a.tar.gz
jthanio-a5512c4b7429c1c8d8d9d8fec83fafcbb4f2255a.tar.bz2
jthanio-a5512c4b7429c1c8d8d9d8fec83fafcbb4f2255a.tar.lz
jthanio-a5512c4b7429c1c8d8d9d8fec83fafcbb4f2255a.tar.xz
jthanio-a5512c4b7429c1c8d8d9d8fec83fafcbb4f2255a.tar.zst
jthanio-a5512c4b7429c1c8d8d9d8fec83fafcbb4f2255a.zip
few cleanups
-rw-r--r--blog/migrations/0002_auto_20200302_2331.py33
-rw-r--r--blog/models.py11
2 files changed, 39 insertions, 5 deletions
diff --git a/blog/migrations/0002_auto_20200302_2331.py b/blog/migrations/0002_auto_20200302_2331.py
new file mode 100644
index 0000000..f90abcb
--- /dev/null
+++ b/blog/migrations/0002_auto_20200302_2331.py
@@ -0,0 +1,33 @@
+# Generated by Django 3.0.3 on 2020-03-02 23:31
+
+from django.db import migrations, models
+import django.db.models.deletion
+import modelcluster.contrib.taggit
+import modelcluster.fields
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('taggit', '0003_taggeditem_add_unique_index'),
+ ('blog', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='BlogPostTag',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('content_object', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='tagged_items', to='blog.BlogPost')),
+ ('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='blog_blogposttag_items', to='taggit.Tag')),
+ ],
+ options={
+ 'abstract': False,
+ },
+ ),
+ migrations.AddField(
+ model_name='blogpost',
+ name='tags',
+ field=modelcluster.contrib.taggit.ClusterTaggableManager(blank=True, help_text='A comma-separated list of tags.', through='blog.BlogPostTag', to='taggit.Tag', verbose_name='Tags'),
+ ),
+ ]
diff --git a/blog/models.py b/blog/models.py
index 34e6e24..71f4b32 100644
--- a/blog/models.py
+++ b/blog/models.py
@@ -1,7 +1,8 @@
from django.db import models
from wagtail.core.models import Page, Orderable
from wagtail.core.fields import RichTextField
-from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanelfrom wagtail.search import index
+from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel
+from wagtail.search import index
from modelcluster.fields import ParentalKey
from modelcluster.contrib.taggit import ClusterTaggableManager
@@ -21,9 +22,9 @@ class BlogIndexPage(Page):
FieldPanel('intro', classname="full")
]
-class BlogPageTag(TaggedItemBase):
+class BlogPostTag(TaggedItemBase):
content_object = ParentalKey(
- 'BlogPage',
+ 'BlogPost',
related_name='tagged_items',
on_delete=models.CASCADE
)
@@ -33,7 +34,7 @@ class BlogPost(Page):
date = models.DateField("Post date")
intro = models.CharField(max_length=250)
body = RichTextField(blank=True)
- tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
+ tags = ClusterTaggableManager(through=BlogPostTag, blank=True)
search_fields = Page.search_fields + [
index.SearchField('intro'),
@@ -47,4 +48,4 @@ class BlogPost(Page):
], heading="Blog information"),
FieldPanel('intro'),
FieldPanel('body'),
- ] \ No newline at end of file
+ ]