#tengo un formulario de registro el cual quiero que se hashee la pasword pero no puedo editar el formulario para obtener la constraseña hashearla para luego setearla y se vea de diferente forma en base de datos
from xml.parsers.expat import model
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Profile(models.Model):
user=models.OneToOneField(User,on_delete=models.CASCADE)
def __str__(self):
return f'perfil de {self.user.username}'
class Usuario(models.Model):
username=models.CharField(max_length=200)
email=models.EmailField(max_length=200)
password=models.CharField(max_length=200)
tipo=models.CharField(max_length=100)
formModel
from pyexpat import model
from django import forms
from .models import Usuario
class FormUsuario(forms.ModelForm):
username = forms.CharField(max_length=200,label="Username")
email=forms.EmailField(max_length=200,label="Email")
password = forms.CharField(max_length=200,label=" password" ,widget=forms.PasswordInput())
public_options=[
(1,'fisio'),
(0,'customer')
]
tipo =forms.TypedChoiceField(
choices=public_options
)
class Meta:
model=Usuario
fields = ['username', 'email', 'password', 'tipo']
field="__all__"
aqui en el view no he podido editar el campo password
def register(request):
if request.method == 'POST':
form = FormUsuario(request.POST)
if form.is_valid():
form.save()
return redirect('login')
else:
form = FormUsuario()
context ={'form':form}
return render(request, 'register.html',context )