Reputation: 3651
My current way of adding new pages to my wagtail site is the following:
Edit the installed apps to include my new page
INSTALLED_APPS = [
'home',
'anotherpage',
'newpage', # this is new
'wagtail.wagtailforms',
...
]
Copy the format of anotherpage
to be my newpage
cp -rf anotherpage newpage
Edit my newpage/models.py
references to anotherpage
to be newpage
.
E.g.
class Anotherpage(Page):
becomes
class Newpage(Page):
And the newpage/migrations/0001_initial.py
references
Rename: mv feedback/templates/info feedback/templates/feedback
and mv feedback/templates/feedback/info_page.html feedback/templates/feedback/feedback_page.html
etc
Then run python manage.py makemigrations
Then python manage.py migrate
Question
This workflow feels quite inefficient, is there a better way to be doing any of the above?
I'm new to python and wagtail. Any insight on what I could be doing better would be greatly appreciated
Upvotes: 1
Views: 1255
Reputation: 25227
You don't have to create a new INSTALLED_APPS
entry and app folder for every new page model you create - a single models.py
file can contain as many page models as you like. Generally I'd recommend one app for each major area of your site - for example, you could have a blog
app containing BlogPage
, BlogIndex
and BlogArchive
page types. You can even define the page models for your entire site in a single app if you want - although that can get hard to maintain when the file grows very large.
This way, creating a new page model just involves adding the class Newpage(Page):
definition to the existing models.py
, running ./manage.py makemigrations
, and adding a new template into the existing template directory.
Additionally, when you do decide to create a new app, you can make use of the ./manage.py startapp some_app_name
command to save having to create files and folders manually.
Upvotes: 3