I've copied the /contrib/auth/views.py into my project and edited it like so

redirect_to = request.META["HTTP_REFERER"]

return render_to_response(template_name, {
    'form': oldforms.FormWrapper(manipulator, request.POST, errors),
    'matts_back_to': redirect_to,
    'site_name': Site.objects.get_current().name,

I've added in my login forms this as the action

<form action="{{ matts_back_to }}" method="post">

Now, when a user comes to a page that shows a view that has this in the top
if request.user.is_authenticated():
    do all your stuff
else:
    return HttpResponseRedirect("/accounts/login")

If they're not logged in they get sent to directly to the login page, they
login and get sent back to the page they were trying to access initially.

This works fine, but for some reason the user is not being shown as having
logged in when they are returned to the initial page.  If they try to access
another secured page at that point, it asks them to login again, and also
the login/logout button is showing as logged out.

Anyone got any ideas why?

If this is a really bad way to achieve what I want then please let me know,
it is a bit of a workaround I suppose.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to