diff options
author | 2021-04-15 16:20:19 +0300 | |
---|---|---|
committer | 2021-05-03 20:19:50 +0300 | |
commit | 3a2635ef50b455b6d846e28971abca60681d9ba4 (patch) | |
tree | 79ab9def868c548e2c56d90c87d9e78aa69d5ddb /pydis_site | |
parent | Add events index redirection (diff) |
Create custom RedirectView to support static arguments
Diffstat (limited to 'pydis_site')
-rw-r--r-- | pydis_site/apps/redirect/views.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pydis_site/apps/redirect/views.py b/pydis_site/apps/redirect/views.py new file mode 100644 index 00000000..9a4bfd65 --- /dev/null +++ b/pydis_site/apps/redirect/views.py @@ -0,0 +1,18 @@ +from django.views.generic import RedirectView + + +class CustomRedirectView(RedirectView): + """Extended RedirectView for manual route args.""" + + permanent = True + static_args = () + + @classmethod + def as_view(cls, **initkwargs): + """Overwrites original as_view to add static args.""" + return super().as_view(**initkwargs) + + def get_redirect_url(self, *args, **kwargs): + """Extends default behaviour to use static args.""" + args = args + self.static_args + return super().get_redirect_url(*args, **kwargs) |