I'm trying to make a password field and hash it to have more security, but it didn't work trying to use form.InputPassword. Someone could help me? :) PS: I saw on stackoverflow using "forms" form django but im doing with models
from django.db import models
from uuid import uuid4
from django import forms
class Cliente(models.Model):
id_usuario = models.UUIDField(auto_created=True, default=uuid4, editable=False)
nome = models.CharField(max_length=100, blank=False, null=False)
senha = models.CharField(max_length=100, blank=False, null=False)
CodePudding user response:
If you wan't to create custom Django User Model, please read the docs first
If you are just interested in how to hash and verify the password manually here is a little code for you to know. But install passlib before that pip install passlib.
from passlib.hash import bcrypt
def hash_password(password: str) -> str:
return bcrypt.hash(password)
def verify_password(password: str, password_hash: str):
return bcrypt.verify(password, password_hash)
