Cannot authenticate users django

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Cannot authenticate users django

I'm having trouble logging in to django. I can't connect, clicking the button works (moves to the next page, but you do not need to enter login details to go there) When entering the password, the user does not matter as if the password has not been checked.
I can only see the html comment when I research the site, all users with their db lists and passwords when I check the login page.
I think I should download the OneToOne field, but it doesn't work for me.
I would ask for help how to do it.

{%if context.error == 'Wrong password'%}
<form action="../home/choosework/" method="post">
   {% csrf_token %}
      <select list="employees" id="peo_login" name="peo_login">
                 <option hidden="">Login</option>
                 {% for login in peoples %}
                   <option value="{{login.peo_login}}">{{ login.peo_name }} {{ login.opr_surname }}</option>
                 {% endfor %}
     <input placeholder="Password" value="{{login.peo_pass}}" type="password" id="peo_pass" name="peo_pass">
     <input type="submit" value="login" />
{% endif %}
class Peoples(models.Model):
    peo_login = models.OneToOneField(User, on_delete=models.CASCADE,
    peo_name = models.CharField(db_column='PEO_NAME', max_length=255, blank=True, null=True) 
    peo_surname = models.CharField(db_column='PEO_SURNAME', max_length=255, blank=True, null=True) 
    peo_pass = models.CharField(db_column='PEO_PASS', max_length=255, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'PEOPLES..
[code=python]def index(request):
    peoples = dbmodel_index.Peoples.objects.all()
    if request.method == 'POST':
        peo_login = request.POST['peo_login']
        peo_pass = request.POST['peo_pass']
        user = authenticate(request, peo_login=peo_login, peo_pass = peo_pass)
        if user:
            login(request, user)
            return HttpResponseRedirect(reversed('login.html'))
            context["error"] = "Wrong password!"
            return render(request, "../home/choosework/", context={'peoples' : peoples})
        return render(request,'login.html', context={'peoples' : peoples})
    return render(request,'login.html', context={'peoples' : peoples})

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit