-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Using page factories for large-scale tree population #46
Comments
The implementation above could easily be built upon to:
|
Intriguing idea, but I'm not clear what would need to be built into Could you be more specific or maybe raise a PR? |
I think part of the issue is the sparse documentation around calling the factories (especially streamfield ones) in ways that will work. Like linking to something like |
@bcdickinson thanks for getting back to me. The idea here is that the Or maybe the entire thing would go into the docs, as hinted at by @easherma-truth? Or, if you don't see a place for this sort of thing in the project at all, that's equally fine. I just thought it would be helpful for others. |
For a lot of projects, it can be helpful to establish the general 'page structure' of a site early on.
In the past, I've used
fixtures
for this, but I find them cumbersome. Every time you decide to switch up your model classes or fields, the fixtures remain unaware and require either a painful 'manual update' process, or a painful 'manually populate the tree locally and re-dump everything' process.In a recent project, I decided that, since we were mostly defining a factory for every page type, we could use factories instead! I came up with the following:
This can then be used to define a 'page tree to create', like so:
This can easily be incorporated into a management command that can trigger creation of all of these pages, like so:
The process safely avoids creating/overwriting pages that already exist - meaning it can be rerun at a later time to add new sections (as the page types are developed)
The text was updated successfully, but these errors were encountered: