Skip to content
Snippets Groups Projects
Commit 99aedb0b authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch 'feature/success-next-mixin' into 'master'

Add SuccessNextMixin for automatic redirecting after finishing an action

See merge request !471
parents c216a427 52116e5b
No related branches found
No related tags found
1 merge request!471Add SuccessNextMixin for automatic redirecting after finishing an action
Pipeline #5724 passed
......@@ -5,6 +5,7 @@ from typing import Any, Callable, List, Optional, Tuple, Union
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.views import LoginView, SuccessURLAllowedHostsMixin
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.managers import CurrentSiteManager
from django.contrib.sites.models import Site
......@@ -415,6 +416,13 @@ class SuccessMessageMixin(ModelFormMixin):
return super().form_valid(form)
class SuccessNextMixin(SuccessURLAllowedHostsMixin):
redirect_field_name = "next"
def get_success_url(self) -> str:
return LoginView.get_redirect_url(self) or super().get_success_url()
class AdvancedCreateView(SuccessMessageMixin, CreateView):
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment