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.

login.html
{%if context.error == 'Wrong password'%}
       {{context.error}}
{%else%}
<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 %}
      </select>
     <br>
     <input placeholder="Password" value="{{login.peo_pass}}" 
type="password" id="peo_pass" name="peo_pass">
     <br>
     <input type="submit" value="login" />
 </form>
{% endif %}

dbmodel_index.py
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..


views.py
[code=python]def index(request):
    peoples = dbmodel_index.Peoples.objects.all()
    context={}
    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'))
        else:
            context["error"] = "Wrong password!"
            return render(request, "../home/choosework/", 
context={'peoples' : peoples})
    else:
        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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d182300a-ed97-4222-9be0-f2bfaae2622b%40googlegroups.com.

Reply via email to