Anil Felipe Duggirala
unread,Jan 7, 2022, 1:04:29 PM1/7/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
hello,
I am using a custom user model.
I have created a form that includes an extra field:
## /users/forms.py
class CustomUserCreationForm(UserCreationForm):
class Meta(UserCreationForm):
model = CustomUser
fields = UserCreationForm.Meta.fields + ('phoneno',)
I am using this form successfully on my user facing signup page (I get username, phoneno and password).
However I would like to achieve the same within the Django admin (have the 'phoneno' field shown).
I have tried to achieve this doing:
## /users/admin.py
class CustomUserAdmin(UserAdmin):
add_form = CustomUserCreationForm
form = CustomUserChangeForm
model = CustomUser
list_display = ['email', 'username', 'phoneno', 'is_staff', ]
However, in the Django admin, when adding a new user, I still face the default form which only has the username and password (no 'phoneno')
thanks for your help.
Anil F