2π
β
The default implementation of login_required
accepts a next
parameter which will cause the user to redirect to that URL after successful login.
https://docs.djangoproject.com/en/dev/topics/auth/default/#the-login-required-decorator
But of course you can recreate this functionality with a few lines.. in your login view, check for the presence of a get
parameter called next
or redirect_url
, then redirect to it upon successful login.
The view sending the user to the login page should simply append `'?next=%s' % request.path
Simple as that.
Source:stackexchange.com