class RedirectURLMixin
from django.contrib.auth.views import RedirectURLMixin
Descendants
Attributes
Defined in | |
---|---|
next_page = None
|
RedirectURLMixin |
redirect_field_name = 'next'
|
RedirectURLMixin |
success_url_allowed_hosts = set()
|
RedirectURLMixin |
Methods
def
get_default_redirect_url(self):
RedirectURLMixin
¶
def
get_default_redirect_url(self):
RedirectURLMixin
¶
Return the default redirect URL.
60 61 62 63 64 | def get_default_redirect_url(self):
"""Return the default redirect URL."""
if self.next_page:
return resolve_url(self.next_page)
raise ImproperlyConfigured("No URL to redirect to. Provide a next_page.")
|
def
get_redirect_url(self):
RedirectURLMixin
¶
def
get_redirect_url(self):
RedirectURLMixin
¶
Return the user-originating redirect URL if it's safe.
45 46 47 48 49 50 51 52 53 54 55 | def get_redirect_url(self):
"""Return the user-originating redirect URL if it's safe."""
redirect_to = self.request.POST.get(
self.redirect_field_name, self.request.GET.get(self.redirect_field_name)
)
url_is_safe = url_has_allowed_host_and_scheme(
url=redirect_to,
allowed_hosts=self.get_success_url_allowed_hosts(),
require_https=self.request.is_secure(),
)
return redirect_to if url_is_safe else ""
|
def
get_success_url(self):
RedirectURLMixin
¶
def
get_success_url(self):
RedirectURLMixin
¶
42 43 | def get_success_url(self):
return self.get_redirect_url() or self.get_default_redirect_url()
|
def
get_success_url_allowed_hosts(self):
RedirectURLMixin
¶
def
get_success_url_allowed_hosts(self):
RedirectURLMixin
¶
57 58 | def get_success_url_allowed_hosts(self):
return {self.request.get_host(), *self.success_url_allowed_hosts}
|