django - How to redirect user after he logs in based on his profile -



django - How to redirect user after he logs in based on his profile -

after user logs in, redirected transfer.html. if user has not created bank account, d redirect him createbankaccount.html instead. how do that? here code

#login.html <form action="." method="post" class="login_form">{% csrf_token %} {{ form.as_p }} <p class="submit"><button type="submit" name="submit" value="login">log in</button></p> {% if next %}<input type="hidden" name="next" value="{{ next }}">{% endif %} </form> #settings.py login_redirect_url = '/main/' #urls.py url(r'^main/$',main_home,name='main_home'), #views.py #this homepage def main_home(request): url = '/%s/trans/create' % request.user.username homecoming httpresponseredirect(url) #i want homepage if user has no bank business relationship def mybank_add(request): url = '/%s/mybank/add' % request.user.username homecoming httpresponseredirect(url)

you're going have write own login method checks count of accounts logged in user has , redirect view want.

django.contrib.auth provides need far forms , methods authenticate user, it's check info need , redirect.

django django-templates django-views

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -