Reputation: 5119
Does anyone know how I might go about updating the string "Landing page group" in the field on the left to "Translation group"?
I'm working on a Wagtail admin page for a Page model. We allow our marketing team to translate pages, and associate them together, using a "landing page group". Internally we need to maintain that name "Landing page group", but our user testing has indicated that users might be more likely to understand what it's for if we simplify the name to "Translation group".
I've already implented a change to the field which allows users to add a new group name. Adding a meta class with verbose_name
was easy. However I'm not having quite as simple of a time renaming the primary selection field. I'm including screenshot of the admin panel in question, and some code below that might offer some insight.
We're using Django 2.0.8 and Wagtail 2.5.1.
class LandingPageGroup(ClusterableModel):
class Meta:
ordering = ['name']
name = models.CharField('Landing Page Group name', max_length=255)
api_fields = [
APIField('name'),
]
def __str__(self):
return self.name
class LandingPageBaseForm(WagtailAdminPageForm):
new_landing_page_group = forms.CharField(required=False, label='New translation group')
class LandingPageBase(Page):
base_form_class = LandingPageBaseForm
landing_page_group = ParentalKey(
'home.LandingPageGroup',
on_delete=models.PROTECT,
blank=True,
null=True,
)
content_panels = [
MultiFieldPanel(
heading='Locale and Hreflang Group',
[
FieldRowPanel(
[
FieldPanel('landing_page_group', widget=forms.Select),
FieldPanel('new_landing_page_group'),
],
help_text='Choose an existing landing page group OR create a new one'
),
],
),
]
Upvotes: 0
Views: 604
Reputation: 5119
It turns out that you can apply a verbose_name
property to the ParentalKey.
landing_page_group = ParentalKey(
'home.LandingPageGroup',
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name='Translation group', # <---
)
I could swear that tried this, but it works as intended.
Upvotes: 1