Search code examples
wagtailwagtail-admin

FieldPanel failed to be reflected on content_panels


I am integrating wagtail into my existing Django project. before integration: file architecture is as below

|- MyProject/
__|- templates/
__|- manage.py
__|- MyProject/
____|- urls.py
____|- models.py
____|- settings.py
____|- views.py

After I installed wagtail packages and reflected that on settings.py, file architecture did not change. Now I can successfully log in to localhost/cms/.

Now I want to customize content_panel of CMS admin, hence I defined below class;

# MyProject/models.py

class HomePage(Page):
    template = "homepage.html"
    content = RichTextField()
    content_panels = Page.content_panels + [
        FieldPanel("content")
    ]

then I migrate database and restart web server, but I did not see any change on content_panels of CMS admin portal. why ?


Solution

  • As mentioned at https://docs.wagtail.io/en/stable/getting_started/integrating_into_django.html#start-developing - when you integrate Wagtail into an existing project (rather than using the wagtail start project template), the initial homepage created will be a basic Page type with no content fields. After you define a real HomePage class, you'll need to delete the initial page and create a HomePage type page in its place (along with creating a Site record under Settings -> Sites).