Django Passwort Probleme
Ich benutze ein Modellformular für Benutzer wie folgt:
class UserForm(forms.ModelForm):
class Meta:
model = User
fields = ('username','password','email',)
, aber das Passwortfeld wird als normales Textfeld und nicht als Passworteingabe angezeigt. Wie stelle ich sicher, dass ein Passwortfeld angezeigt wird?
Ich habe es versucht:
class UserForm(forms.ModelForm):
username = forms.CharField(max_length = 15, min_length = 6)
password = forms.PasswordInput()
class Meta:
model = User
fields = ('username','password','email',)
Aber das funktioniert auch nicht.
Ich versuche auch, ein Bestätigungskennwortfeld hinzuzufügen, aber dies führt dazu, dass keine Felder angezeigt werden:
class UserForm(forms.ModelForm):
username = forms.CharField(max_length = 15, min_length = 6)
password = forms.PasswordInput()
cpassword = forms.PasswordInput()
def clean(self):
if self.cleaned_data['cpassword']!=self.cleaned_data['password']:
raise forms.ValidationError("Passwords don't match")
class Meta:
model = User
fields = ('username','password','cpassword','email',)