Skip to content

Commit

Permalink
Fix support for Django 4.1
Browse files Browse the repository at this point in the history
The SuccessURLAllowedHostsMixin was replaced by RedirectURLMixin as per Django 4.1 documentation "The undocumented django.contrib.auth.views.SuccessURLAllowedHostsMixin mixin is replaced by RedirectURLMixin."

Source
https://docs.djangoproject.com/en/4.1/releases/4.1/
  • Loading branch information
alahdal authored and sergei-maertens committed Sep 4, 2022
1 parent c98de3d commit 54f5e5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions cookie_consent/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
from django.utils.http import url_has_allowed_host_and_scheme
except ImportError: # django < 3.0
from django.utils.http import is_safe_url as url_has_allowed_host_and_scheme

try: # django >= 4.1
from django.contrib.auth.views import RedirectURLMixin
except ImportError:
from django.contrib.auth.views import SuccessURLAllowedHostsMixin as RedirectURLMixin
5 changes: 2 additions & 3 deletions cookie_consent/views.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# -*- coding: utf-8 -*-
from django.core.exceptions import SuspiciousOperation
from django.contrib.auth.views import SuccessURLAllowedHostsMixin
from django.http import HttpResponseRedirect, HttpResponse
from django.urls import reverse
from django.views.generic import (
ListView,
View,
)

from .compat import url_has_allowed_host_and_scheme
from .compat import RedirectURLMixin, url_has_allowed_host_and_scheme
from .models import (
CookieGroup,
)
Expand All @@ -25,7 +24,7 @@ class CookieGroupListView(ListView):
model = CookieGroup


class CookieGroupBaseProcessView(SuccessURLAllowedHostsMixin, View):
class CookieGroupBaseProcessView(RedirectURLMixin, View):

def get_success_url(self):
"""
Expand Down

0 comments on commit 54f5e5f

Please sign in to comment.