last day (14 days later) » 

6:50 AM
0
A: Do not want to prompt login screen again for the user after he register and log's in first time. Django

user2719875Which view is called when the user clicks the login button? Is the login_android view called when the user clicks the login button? If yes, add these lines at the beginning of the view: from django.conf import settings def login_android(request): if request.user.is_authenticated(): r...

 
where should i add this lines from django.conf import settings def login_android(request): if request.user.is_authenticated(): return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL)
 
@GauravWagh which view is called when the login button is clicked?
 
login_android view after he clicks on login view
 
@GauravWagh add 'from django.conf import settings' at the beginning of your views.py and add "if request.user.is_authenticated(): return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL)" at the beginning of the login_android view (right before the "print 'i am in view'" line)
 
but it will not work. because in ajax success function i am redirecting to the one seprate html page which is not is not included in django application. its in android application.
 
6:50 AM
@GauravWagh what does auth.login(request,user) redirect to?
you there?
 
hay hi
 
okay so
do you know what auth.login(request,user) redirects to?
 
i am using django backend for android application
 
okay then try this
 
so there are two options on main screen register and login
 
6:52 AM
from django.conf import settings
def login_android(request):
if request.user.is_authenticated():
auth.login(request,user)
def login_android(request):
if request.user.is_authenticated():
auth.login(request,user)
whoops, I sent it twice by accident
don't forget to indent
does that work?
 
let me check
 
sure
 
its not working its going to else part
def login_android(request):
print "i am in view"
if request.user.is_authenticated():
#return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL)
print "you in"
auth.login(request,user)
else:
if request.method == "POST":
you there
?
 
hm
well then the user isn't signed in
request.user.is_authenticated checks if the user is signed in or not
of it goes to else, then it means the user is not signed in
 
but user is getting signed in
hay its getting in if request.user.is_authenticated(): this
now
 
7:02 AM
yea
 
but getting error after that UnboundLocalError: local variable 'user' referenced before assignment
 
if user is signed in, it WILL get i n request.user.is_authenticated() and if the user is not signed in, then it wont
which line is that error message pointing to?
 
auth.login(request,user)
i will be back within 10 minutes
 
before auth.login(request,user), type in
 
Thanks friend
 
7:04 AM
user = request.user
so overall
 
def login_android(request):
if request.user.is_authenticated():
user = request.user
auth.login(request, user)
that should work
 
7:24 AM
does it work?
 
i am checking that
 
8:00 AM
If it works, please accept the answer
 
thanks Its working now
 

last day (14 days later) »