Skip to content

Instantly share code, notes, and snippets.

@rogersdepelle
Created February 12, 2020 15:39
Show Gist options
  • Save rogersdepelle/31e955e56f3d7bf553ba1e2fa2d7520c to your computer and use it in GitHub Desktop.
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}}">
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