I feel like this is an easy question and I\'m just missing 1 small step.
I want to do any number of the following (as the term in the next parameter):
What I have ended up doing is the following. To me this seems like a bit of a hack job. Is there any better way to use login with a csrf?
views:
def login(request):
c={}
c.update(csrf(request))
if 'next' in request.GET:
c['next'] = request.GET.get('next')
return render_to_response('login.html', c)
def auth_view(request):
username = request.POST.get('username', '')
password = request.POST.get('password', '')
user = auth.authenticate(username=username, password=password)
if user is not None:
auth.login(request, user)
if request.POST.get('next') != '':
return HttpResponseRedirect(request.POST.get('next'))
else:
return HttpResponseRedirect('/accounts/loggedin')
else:
return HttpResponseRedirect('/accounts/invalid')
login.html: