I created a reusable abstract model (mixin) which includes required fields (without blank=True). Then added to a page model inline model which inherits that mixin. Finally I cannot save a page despite I filled in all the required fields. My app crashes with a message those fields cannot be blank. When I eliminate required option everything works well. The same thing if I use this model obviously (as pure inline model, not a mixin) with required fields. What's wrong here? If my approach is quite complicated, what is a better way to reuse code in this case?
Mixin:
class ContentSectionOneMixin(models.Model):
class Meta:
abstract = True
content_section_one_title = models.TextField(_('Title'), null=True)
content_section_one_body = RichTextField(_('Lead'), null=True)
content_section_button_caption = RichTextField(
_('Caption'),
null=True,
blank=True
)
content_panels = [
MultiFieldPanel(
heading=_('Content Section One'),
children=[
FieldPanel('content_section_one_title'),
FieldPanel('content_section_one_body'),
FieldPanel('content_section_button_caption'),
],
classname='collapsible collapsed'
),
]
Inline model
class HomePageContentFlow(Orderable, ContentSectionOneMixin):
page = ParentalKey('HomePage', related_name='content_flow')
panels = ContentSectionOneMixin.content_panels