I am new to Django and I want to make a user registration form in Django. While creating model, I gave a fieldtype->PasswordField() to password field but when I run this model i
There is no PasswordField()
in django. You can to use CharField()
to store a password, but to show it as password input type in a html form you can specify a widget to it.
Example:
password = forms.CharField(widget=forms.PasswordInput())
More reference at :PasswordInput
Use django.db.models.CharField, since this is an OK database column type for a password string
Use django.forms.PasswordWidget, to represent this field in a form, see overriding default form field widgets
models.py:
from django.db import models
class YourModel(models.Model):
password = models.CharField(max_length=200)
forms.py:
from django import forms
from models import YourModel
class YourModelForm(forms.ModelForm):
class Meta:
widgets = {'password': forms.PasswordField}
model = YourModel