python - Trying to Query on Login and based on email and password return First Name -


i have sqlite database with: first_name email password andrew t@t.com abcde

i using check if there matching email , password:

if user.usermanager.filter(email = postdata['email'], password =  postdata['password']):             name = user.usermanager.filter(email = postdata['email'], password = postdata['password'])             print name.get('first_name')             return "success" 

when try print first_name query did above error 'too many values unpack'

this happening because get() method expecting keyword arguments: https://docs.djangoproject.com/en/1.11/ref/models/querysets/#get

the queryset returned filter() method contain more 1 entry: https://docs.djangoproject.com/en/1.11/ref/models/querysets/#filter , should specify expected value requested field.

one of ways access value is:

print name.get(first_name='andrew').first_name 

on other hand, limit filter query:

user.usermanager.filter(email = postdata['email'], password = postdata['password'])[:1] 

or use get() method straightway , access field value directly:

user = user.usermanager.get(email = postdata['email'], password = postdata['password']) print user.first_name 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -