Password field via ajax in Dajngo

Asked

Viewed 21 times

0

Hello, I want to fill the password field of my model Company in sending the value typed via post ajax, I saw that there is the Passwordinput widget when using modelform but I did not want to use modelform and yes via ajax, it is mandatory to use modelform to save passwords?

My model:

from django.db import models

class Company(models.Model):
    name = models.CharField(max_length=150, blank=False, null=False)
    email = models.EmailField( max_length=254, blank=False, null=False)
    password = models.CharField(max_length=150, blank=False, null=False)
  • 1

    No, you don’t have to, no matter where the information comes from, in your view you can process it however you need to and save it in the bank.

1 answer

0

Tip: You can hash your password inside your view, and save to the Field you want.

from django.contrib.auth.hashers import make_password, check_password

hashed_pwd = make_password("plain_text")
check_password("plain_text",hashed_pwd)  

Browser other questions tagged

You are not signed in. Login or sign up in order to post.