Created
February 12, 2020 15:39
-
-
Save rogersdepelle/31e955e56f3d7bf553ba1e2fa2d7520c to your computer and use it in GitHub Desktop.
NextURLMixin: Mixin to return to the source page after performing some action, Example of use <a href="{{object.get_update_url }}?next={{request.path}}">
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NextURLMixin: | |
""" Use next variable by GET method to set success url """ | |
def get_success_url(self): | |
next_url = self.request.GET.get('next') | |
if next_url: | |
return next_url | |
return reverse('home') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment