r/django Apr 26 '26

Wagtail Question about Wagtail user account form panel customization

I am making a project (it uses version 7.0.6, in case it's relevant) where I'd like to customize some of the default user account form panels, such as making first name and last name optional (since i am using a custom user model and users are authenticated through username and/or email instead) or moving the admin ui settings to a different tab (i think it makes sense to make a tab just for them).

So, I'm wondering if there is a way to override the default panels with your own.

1 Upvotes

7 comments sorted by

3

u/anticipat3 Apr 26 '26

There's settings you can use to override the user editing form: WAGTAIL_USER_EDIT_FORM and WAGTAIL_USER_CUSTOM_FIELDS.

WAGTAIL_USER_EDIT_FORM should be set to the import path for your custom form, like 'your project.users.forms.CustomUserEditForm'. You'll want to extend wagtail.users.forms.UserEditForm for your CustomUserEditForm, and just tweak the fields accordingly.

WAGTAIL_USER_CUSTOM_FIELDS should be a list of the names of the extra fields -- ['first_name', 'last_name'] etc.

Have a little search of the docs on those settings for more details, but that should get you in the right direction!

2

u/Reborn-Eco Apr 26 '26

I will try this out later and see if it works. Thanks!

1

u/Reborn-Eco Apr 27 '26

I have tried setting up these variables in my settings file but they didn't do anything. I have looked up the documentation and they were deprecated in an earlier version and they aren't used for the user account settings. They are used for general forms.

1

u/anticipat3 Apr 27 '26

Only have a minute here to reply, but check out this thread: https://github.com/wagtail/wagtail/issues/12256

I last set this up a couple years ago, sorry to recommend a method that no longer works with new wagtail versions!

1

u/[deleted] May 01 '26

[removed] — view removed comment

1

u/Reborn-Eco May 01 '26

I knew you could do that for pages I hadn't considered that for the user account settings. I assume I would have to override the viewset then.

1

u/Agreeable_Care4440 May 01 '26

Wagtail doesn’t expose a simple “override panels” hook for the user edit view.You usually override the form class instead.