1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
wagtail-website-2018-spike/project/blog/models.py

33 lines
869 B
Python
Raw Normal View History

2018-07-26 08:44:14 +01:00
from project.common.blocks import build_stream_field
2018-07-26 21:48:30 +01:00
from wagtail.admin.edit_handlers import StreamFieldPanel, FieldPanel
2018-07-26 08:44:14 +01:00
from wagtail.search import index
from project.common.models import Entity
2018-07-26 21:48:30 +01:00
from django.db import models
from modelcluster.fields import ParentalKey
from modelcluster.contrib.taggit import ClusterTaggableManager
from taggit.models import TaggedItemBase
class BlogPageTag(TaggedItemBase):
content_object = ParentalKey(
'BlogPage',
related_name='tagged_items',
on_delete=models.CASCADE
)
2018-07-26 08:44:14 +01:00
class BlogPage(Entity):
body = build_stream_field()
2018-07-26 21:48:30 +01:00
tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
2018-07-26 08:44:14 +01:00
search_fields = Entity.search_fields + [
index.SearchField('body'),
]
content_panels = Entity.content_panels + [
StreamFieldPanel('body'),
2018-07-26 21:48:30 +01:00
FieldPanel('tags')
]