Chris Hansen
Chris Hansen

Reputation: 8655

django facebook how to redirect back to previous page

I am using the django facebook app, how do I get the user redirected back to previous page after login ?

I tried to use the "next" hidden input box, but that did not work .

<input type = "hidden" name = "next" value = "{{ request.GET.next }}" />

Upvotes: 0

Views: 219

Answers (1)

Tommi Un
Tommi Un

Reputation: 173

from the Django-facebook docs:

In settings.py you can set

FACEBOOK_LOGIN_DEFAULT_REDIRECT = "/whatever/"

to change the default-redirect.

edit

Another way is to subclass the facebook-app's custom backend like so (excerpt from the docs):

from django_facebook.registration_backends import FacebookRegistrationBackend

class CustomBackend(FacebookRegistrationBackend):
    def post_connect(action):
        # go as crazy as you want, just be sure to return a response
        response = HttpRedirect('/something/')
        if action is CONNECT_ACTIONS.LOGIN:
            response = HttpRedirect('/')
        return response

post_connect handles the redirect after connecting.

Upvotes: 0

Related Questions