from django.core.urlresolvers import reverse

def login(request):
    if request.session.get('user'):
        return HttpResponseRedirect(reverse('my-named-url'))
Django and urls.py: How do I HttpResponseRedirect via a named url?