Django Admin: Add possibility of role distribution ?

Hi again folks,
I`m asking, whether it is possible (through editing of my accounts/admin.py ?) to configure DJANGO admin site to provide possibility of adding Name, Surname, eMail Adress and planned roles directly within the form for adding a new user?

Normally, you have to add a user, click back in the user account, add Name, Surname, eMail adress and assign roles (or not)…I would like to shorten this process to being able to do this right upon registration…

Is it possible to do this? Yes.

However, it would actually be less work to create your own “Add user” view to do it.

From what I can see, changing the behavior of the existing admin class would require something along the lines of:

  • Unregister the default ModelAdmin class for User.
  • Register your own ModelAdmin class for the model
  • Override the admin/auth/user/add_form.html template.
  • Override the add_fieldsets attribute
  • Override the add_form attribute to use a custom UserCreationForm
  • Create the custom UserCreationForm

By the time you’ve done that, you could have already created a CreateView using that same custom UserCreationForm for this.

1 Like

Thx once more Ken,

You showed me a way I can understand. But as it sounds like at least a bit of work and
as it is a pure convenience problem, i will deal with this as soon as i have a little spare time for it :slight_smile: