Defining a custom "title": Override a Page model's save() method?

366 views
Skip to first unread message

Ryan Nevius

unread,
Aug 27, 2015, 6:56:46 PM8/27/15
to Wagtail support
This issue on Github essentially sums up what I'm trying to do. I have a custom Page model called TeamMember, which is used to define members of a team. As a result, I'd like to rename/relabel the page "title" to be "name" in the Admin, and have that field be used for the Wagtail "title".

What is the preferred method of doing this? I'm assuming I should add a new model field called "name" and override the TeamMember .save() method to have the "title" default to the "name" of the team member.

Am I on the right track here? Or is there a different / better way to do this?

Brett Grace

unread,
Aug 31, 2015, 9:47:22 PM8/31/15
to Wagtail support
Wagtail builds a ModelForm class for each of the page types when the app boots. You can get a reference to it and set the label dynamically. I did this as a proof of concept, and it does work, but I didn't actually deploy it, since the benefit for my situation was not worth risk of depending on private implementation details.

While I know that this is a desired feature, I'm not aware if it has been pinned to a milestone yet, I haven't been following the issue tracker for a while.  
Reply all
Reply to author
Forward
0 new messages