Hi , thanks for sharing this unique post. Just one thing I want to ask is about form section-
You have created 2 forms- Usrcreationform and registration form . Both are inherited from forms.ModelForm . Why you have written 2 different forms and used only 1? I am asking this as I want to add "confirm password field" in registration form that you have written in User Creation form.
RegistrationForm is used by the public-facing RegistrationView.
I use a separate form because it can include registration specific code that is not needed in the backend User Creation process (e.g captcha field, label, help text).
You can customize it to fit your requirements.
UserCreationForm and UserChangeForm are used by the auto-generated Django Admin backend.
The need to be rewritten since they are tied to the inbuilt User model as explained here
The relevant code is in accounts/admin.py:
...
class AccountAdmin(BaseUserAdmin):
form = UserChangeForm
add_form = UserCreationForm
...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi , thanks for sharing this unique post. Just one thing I want to ask is about form section-
You have created 2 forms- Usrcreationform and registration form . Both are inherited from forms.ModelForm . Why you have written 2 different forms and used only 1? I am asking this as I want to add "confirm password field" in registration form that you have written in User Creation form.
Hi Rahul,
RegistrationForm
is used by the public-facingRegistrationView
.I use a separate form because it can include registration specific code that is not needed in the backend User Creation process (e.g captcha field, label, help text).
You can customize it to fit your requirements.
UserCreationForm
andUserChangeForm
are used by the auto-generated Django Admin backend.The need to be rewritten since they are tied to the inbuilt User model as explained here
The relevant code is in
accounts/admin.py
: