Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14126

function on Django to check user in database

$
0
0

I want to write a function to check a user in the database, can anyone help?can someone help i am learning DjangoI try many ways but ...------------view.py----------------

def user_enter(request):     print("hello")     if request.method == "POST":        enter_user_email=request.POST.get('enter_user_email')        enter_user_pass=request.POST.get('enter_user_pass')        print(enter_user_pass)        print(enter_user_email)        data=User.objects.filter(email_name = enter_user_email,user_password = enter_user_pass).exists()     return render(request, 'main.html',{'data':data})

--------------HTML---------------

<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Title</title><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"><link rel="stylesheet" href="static/css/style.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"></head><body><div class="container mx-auto mt-2" style="width: 500px;" id="input_name_pass"><img src="static/user.png" alt="..."  id='user_image' class="img-thumbnail mx-auto" style="width: 200px;"><form action="" method = "POST">        {% csrf_token %}<div class="input-group input-group-sm mb-3 mt-4"><div class="input-group-prepend"><span class="input-group-text" id="inputGroup-sizing-sm">User</span></div><input type="text" class="form-control" aria-label="Small" aria-describedby="inputGroup-sizing-sm" name = "enter_user_email"></div><div class="input-group input-group-sm mb-3"><div class="input-group-prepend"><span class="input-group-text" id="inputGroup-sizing-sl">Pass</span></div><input type="password" class="form-control" aria-label="Small" aria-describedby="inputGroup-sizing-sm" name = "enter_user_pass"></div><button type="submit"  class="btn btn-primary mt-3" onclick="location.href='{% url 'user_enter' %}'">Enter</button></form><button type="button"  class="btn btn-primary mt-3" onclick="location.href='{% url 'user_registration' %}'">Create User</button></div><script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script><script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script><script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script></body></html>

Viewing all articles
Browse latest Browse all 14126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>