0

Actually i new to django framework. Here my doubt is, can we create two password fields for password validation one is password and second is confirm password for user registration template or can we manage only one password field. Let anyone please give the clarification for that.

Here is example model:

class new_user(models.Model):

   name = models.CharField()
   email = models.EmailField()
   password = models.CharField()
   confirmpassword = models.CharField()

or else can we manage only one password field like below :

 class new_user(models.Model):

   name = models.CharField()
   email = models.EmailField()
   password = models.CharField()
user 98
  • 167
  • 2
  • 12
  • You may check this https://stackoverflow.com/questions/34609830/django-modelform-how-to-add-a-confirm-password-field – S.N Apr 04 '20 at 10:34
  • Actually whatever fields are available in model class that fields we have to take in model form. – user 98 Apr 04 '20 at 10:38
  • My question is, how many password fields can I take in model for that validating the password and confirm password in template – user 98 Apr 04 '20 at 10:39
  • Generally you don't have a `confirmpassword` field on the model because there is no need to store the value. `password` and `confirmpassword` are compared in the view; if they match, save `password`, if they don't, tell the user there's a problem. In either case, `confirmpassword` can be discarded once the comparison has taken place. – snakecharmerb Apr 05 '20 at 08:09
  • @snakecharmerb thanks. Actually I am looking for this kind of answer. Could please elaborate the answer with few more lines.. – user 98 Apr 06 '20 at 02:37

0 Answers0