Reputation:
I want to learn somethings about User Authentication.. I want to import UserCreationForm to my forms.py without "password field" and then I want to make password field and control by myself. How can I exclude "password fields"? thanks for help.
Upvotes: 6
Views: 4918
Reputation: 2578
Your best option is to hide them from the form:
class MyUserCreationForm(UserCreationForm):
password1 = None # Standard django password input
password2 = None # Standard django password confirmation input
EDIT: Actually this is only hiding the form, but you will have problems during form validation. Still looking for a solution.
Upvotes: 2
Reputation: 3631
Just delete them in __init__
and update methods where they are used:
class MyUserCreationForm(UserCreationForm):
def __init__(self, *args, **kwargs):
super(MyUserCreationForm, self).__init__(*args, **kwargs)
del self.fields['password1']
del self.fields['password2']
Upvotes: 15