New management command: startpage [page] #11378
Replies: 8 comments
-
e.g. creates from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
class BlogPage(Page):
body = RichTextField(blank=True)
content_panels = Page.content_panels + [
FieldPanel("body", classname="full"),
] and {% extends "base.html" %}
{% load wagtailcore_tags %}
{% block content %}
{{ page.body|richtext }}
{% endblock %} ? |
Beta Was this translation helpful? Give feedback.
-
The template I would not do as mostly you create in in templates separate folder, maybe I can write this as contribution in wagtail? |
Beta Was this translation helpful? Give feedback.
-
We do something similar in Wagtail-Pipit. |
Beta Was this translation helpful? Give feedback.
-
You would probably have to include the app name when you create the new model. This would be similar to other standard django commands where you have to supply the app name with the model name to namespace it:
|
Beta Was this translation helpful? Give feedback.
-
I'm undecided on this... this would essentially be codifying the rule "every new page type belongs in its own app" as best practice, and I'm not sure if that's too opinionated for Wagtail itself. (It's certainly a better idea than putting everything in one enormous app, but I'd say it's equally valid to put a group of related page types in one app - e.g. a I'd be perfectly happy to see something like this in an add-on package though. If anything, I'd argue that the rule "you should keep your templates inside the app folder" is more standardised and less controversial, so if we were to go ahead with this, I'd be in favour of including the template too. |
Beta Was this translation helpful? Give feedback.
-
I don't see the problem, grouping models in one app is good practice. But maybe it should call then ./manage.py start_wag --models BlogPage BlogIndex BlogCategoryPage . Maybe some name suggestions:
|
Beta Was this translation helpful? Give feedback.
-
I agree with gasman that this is a pretty good case for a third party library. |
Beta Was this translation helpful? Give feedback.
-
I’m going to convert this to Discussions to make this a bit more visible. Cool idea, unsure whether it’s clear enough of an API to be implemented in core while leaving room for everyone’s opinions on how this should work. |
Beta Was this translation helpful? Give feedback.
-
Wouldn't it be nice to have a command ./manage.py startpage in wagtail
it only should have the dir name [page] and init.py and models. The model can then be prefilled with a class and the some imports that are common.
just a suggestion
https://docs.wagtail.io/en/stable/reference/management_commands.html
Beta Was this translation helpful? Give feedback.
All reactions