0

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 }}" />
Chris Hansen
  • 7,813
  • 15
  • 81
  • 165

1 Answers1

0

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.

Tommi Un
  • 173
  • 1
  • 9
  • can you do that without using settings.py? as a post for example? – Chris Hansen Nov 27 '14 at 07:32
  • Can I pass the page I want it redirect to via post and that gets passed back when we get back from facebook back to the site? Basically, if they login via facebook on page A, i want to pass page A's url to Facebook and then back to the site so that the user gets redirected back to page A when he returns back to the site. – Chris Hansen Nov 28 '14 at 01:34