from django.db import models from modelcluster.fields import ParentalKey from wagtail.core.models import Page, Orderable from wagtail.core.fields import RichTextField from wagtail.admin.edit_handlers import FieldPanel, InlinePanel from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.search import index class Katalog(Page): parent_page_types = ['home.HomePage', ] subpage_types = ['Kniha', ] class Kniha(Page): podnadpis = models.CharField(max_length=128, verbose_name='Podnadpis', null=True, blank=True) datum_vydani = models.DateField("Datum vydání") autor = models.CharField(max_length=128, verbose_name='Autor') anotace = RichTextField(blank=True) obrazek = models.ForeignKey('wagtailimages.Image', on_delete=models.PROTECT, related_name='+') parent_page_types = ['Katalog', ] search_fields = Page.search_fields + [ index.SearchField('anotace'), ] content_panels = Page.content_panels + [ FieldPanel('podnadpis'), FieldPanel('autor'), FieldPanel('datum_vydani'), FieldPanel('anotace', classname="full"), ImageChooserPanel('obrazek'), ]