I\'m writing a member-based web application, and I need to be able to redirect the page after login. I want to use the named url from my urls.py script in my views.py file f
A more concise way to write that if statement would be if request.session.get('user'). has_key is deprecated nowadays, and .get() returns None (by default, changeable by passing a second parameter).
So combining this with Soviut's reply:
from django.core.urlresolvers import reverse
def login(request):
if request.session.get('user'):
return HttpResponseRedirect(reverse('my-named-url'))