from wagtail.core.fields import RichTextField from wagtail.core.models import Page class CustomPage(Page): """A custom Page model with a RichTextField for main content""" # Use RichTextField for the content field content = RichTextField() # Add additional fields as needed best for your use case full_name = models.CharField(max_length=255, null=True, blank=True) # Add any additional meta data relevant to your use case class Meta: ordering = ['-first_published_at'] verbose_name = "Custom Page Model" verbose_name_plural = "Custom Page Models"
from wagtail.admin.edit_handlers import FieldPanel from wagtail.core.models import Page class CustomPage(Page): """A custom Page model with a RichTextField for main content""" # Use RichTextField for the content field content = RichTextField() # Add additional fields and panels as needed full_name = models.CharField(max_length=255, null=True, blank=True) # Add any additional meta data relevant to your use case class Meta: ordering = ['-first_published_at'] verbose_name = "Custom Page Model" verbose_name_plural = "Custom Page Models" # Define panels to add custom fields to the CMS editor view content_panels = Page.content_panels + [ FieldPanel('full_name'), FieldPanel('content'), ]In this example, we create a CustomPage model with a content field defined as a RichTextField. We then also define custom FieldPanels and add them to the Page.content_panels list. These will enable fields to show in the Wagtail editor view. In conclusion, RichTextField is a powerful Wagtail field that provides formatting, embedding, and media options for content creation. Using it in a model is as simple as defining the field and adding it to the relevant panels.