Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- from wagtail.core.fields import RichTextField
- from wagtail.search import index
- from wagtail.admin.edit_handlers import FieldPanel, PageChooserPanel
- from wagtail.images.edit_handlers import ImageChooserPanel
- class Banner(models.Model):
- """Banner mixin for a page."""
- banner_title = models.CharField(max_length=140, blank=True)
- # Rich text field limited to 2 options.
- banner_text = RichTextField(blank=True, features=["bold", "italic"])
- banner_image = models.ForeignKey(
- "wagtailimages.Image",
- null=True,
- blank=True,
- on_delete=models.SET_NULL,
- related_name="+",
- help_text="Upload a banner image to this page"
- )
- panels = [
- FieldPanel("banner_title"),
- FieldPanel("banner_text"),
- ImageChooserPanel("banner_image"),
- ]
- search_fields = [
- index.SearchField("banner_title"),
- index.SearchField("banner_text"),
- ]
- class Meta:
- """Abstract Model."""
- abstract = True
Add Comment
Please, Sign In to add comment