Created
July 21, 2018 19:11
-
-
Save KalobTaulien/fd647fabfb5210203c697dc5694d2633 to your computer and use it in GitHub Desktop.
Wagtail 2: Changing the title and help text of a default Wagtail Page field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from wagtail.core.models import Page | |
class YourPage(Page): | |
"""Your Wagtail Page Type.""" | |
template = "templates/your_page.html" | |
# Other Page fields | |
YourPage._meta.get_field('title').verbose_name = 'New Default Title' | |
YourPage._meta.get_field('title').help_text = 'New Help Text For Default Title' |
Thanks @gasman for your input. Here is my solution to override default title information (maybe it will help others). No more issues when migrating in production 👍
class CoursePageForm(WagtailAdminPageForm):
title = forms.CharField(max_length='255',
label="Custom label",
help_text="Custom help text",
widget=forms.TextInput(attrs={'placeholder': "Custom placeholder"})
)
class CoursePage(Page):
image = models.ForeignKey(
'wagtailimages.Image',
blank=True,
null=True,
on_delete=models.SET_NULL,
related_name="+",
verbose_name="bla bla"
)
description = models.TextField(blank=True, verbose_name="Bla bla bla")
content_panels = Page.content_panels + [
MultiFieldPanel(
[
FieldPanel('image'),
FieldPanel('description'),
], heading="Cours"
),
]
base_form_class = CoursePageForm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gasman many thanks for your quick reply!