-1
good afternoon!
I’m starting in WEB programming and I ended up bumping into a problem with Django in the authentication issue. I’ve read all the documentation that talks about Django’s Custom Auth but I haven’t found a solution yet. Based on the model below I created a form for inclusion of users in the system and it is working normally, but I can not leave this point to authenticate using the model below, because I intend to relate fields of this table later in other functionalities of the system.
Models py.
class User(models.Model):
ATIVO_CHOICES=[("ATIVO","ATIVO"),("INATIVO","INATIVO")]
BLOQUEADO_CHOICES=[("BLOQUEADO","BLOQUEADO"),("DESBLOQUEADO","DESBLOQUEADO")]
user_cod = models.AutoField(primary_key=True)
user_nome = models.CharField("Nome Completo",max_length=250, blank=False, null=False)
user_email = models.EmailField("Email",unique=True, blank=False)
user_ativo = models.CharField("Situação",max_length=25,choices=ATIVO_CHOICES, blank=False, null=False)
user_bloqueado = models.CharField("Bloqueado?",max_length=25,choices=BLOQUEADO_CHOICES, blank=False, null=False)
user_cpf = models.CharField("CPF",max_length=11, blank=False, null=False, unique=True, validators=[validate_CPF])
user_senha = models.CharField("Senha",max_length=250, blank=False, null=False)
class Meta:
managed = False
db_table = 'user'
Forms py.
class UserForm(forms.ModelForm):
class Meta:
model = User
fields = '__all__'
widgets = {'user_senha': forms.PasswordInput()}
py views.
def user_create(request):
submitted = False
if request.method == 'POST':
form = UserForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
# assert False
form.save()
return HttpResponseRedirect('/userlist')
I wanted to continue using this screen this way, but now I need to authenticate users created and stored in this database without affecting this code.