from django.shortcuts import redirect from django.http import HttpResponseRedirect class RedirectNextMixin: def redirect_to_next(self, request): """ If a 'next' parameter was specified, redirect to the next page. This is used when the user is required to return to some page after the current view has finished its work. """ if 'next' in request.GET: next_page = request.GET['next'] return HttpResponseRedirect(next_page) else: return redirect('index')