Guest User

Untitled

a guest
Jul 21st, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. from django.db import models
  2.  
  3. from wagtail.core.fields import RichTextField
  4. from wagtail.search import index
  5. from wagtail.admin.edit_handlers import FieldPanel, PageChooserPanel
  6. from wagtail.images.edit_handlers import ImageChooserPanel
  7.  
  8.  
  9. class Banner(models.Model):
  10. """Banner mixin for a page."""
  11.  
  12. banner_title = models.CharField(max_length=140, blank=True)
  13. # Rich text field limited to 2 options.
  14. banner_text = RichTextField(blank=True, features=["bold", "italic"])
  15. banner_image = models.ForeignKey(
  16. "wagtailimages.Image",
  17. null=True,
  18. blank=True,
  19. on_delete=models.SET_NULL,
  20. related_name="+",
  21. help_text="Upload a banner image to this page"
  22. )
  23.  
  24. panels = [
  25. FieldPanel("banner_title"),
  26. FieldPanel("banner_text"),
  27. ImageChooserPanel("banner_image"),
  28. ]
  29. search_fields = [
  30. index.SearchField("banner_title"),
  31. index.SearchField("banner_text"),
  32. ]
  33.  
  34. class Meta:
  35. """Abstract Model."""
  36.  
  37. abstract = True
Add Comment
Please, Sign In to add comment