10 examples of 'httpresponseredirect django' in Python

Every line of 'httpresponseredirect django' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
14def redirect_view(request):
15 return HttpResponseRedirect(target)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

24def redirect(request,path):
25 """Redirect old talk.org blog posts"""
26 return HttpResponsePermanentRedirect("http://neubia.com/archives/%s"%path)
14def redirect(request):
15 return HttpResponseRedirect('/')
9def redirect(url):
10 return lambda res: HttpResponseRedirect(url)
32def redirect_to(request, url):
33 return HttpResponseRedirect(url)
21def f_redirect(req):
22 from django.http import HttpResponseRedirect
23 return HttpResponseRedirect(settings.REDIRECT_URL)
227def redirect(self):
228 """Redirect to matching SVG badge."""
229 kwargs = {
230 'project': self.obj.slug,
231 'widget': 'svg',
232 'color': 'badge',
233 'extension': 'svg',
234 }
235 if self.lang:
236 kwargs['lang'] = self.lang.code
237 return reverse('widget-image', kwargs=kwargs)
238 return reverse('widget-image', kwargs=kwargs)
29def default_redirect(request, fallback_url, **kwargs):
30 redirect_field_name = kwargs.get("redirect_field_name", "next")
31 next_url = request.POST.get(redirect_field_name, request.GET.get(redirect_field_name))
32 if not next_url:
33 # try the session if available
34 if hasattr(request, "session"):
35 session_key_value = kwargs.get("session_key_value", "redirect_to")
36 if session_key_value in request.session:
37 next_url = request.session[session_key_value]
38 del request.session[session_key_value]
39 is_safe = functools.partial(
40 ensure_safe_url,
41 allowed_protocols=kwargs.get("allowed_protocols"),
42 allowed_host=request.get_host()
43 )
44 if next_url and is_safe(next_url):
45 return next_url
46 else:
47 try:
48 fallback_url = reverse(fallback_url)
49 except NoReverseMatch:
50 if callable(fallback_url):
51 raise
52 if "/" not in fallback_url and "." not in fallback_url:
53 raise
54 # assert the fallback URL is safe to return to caller. if it is
55 # determined unsafe then raise an exception as the fallback value comes
56 # from the a source the developer choose.
57 is_safe(fallback_url, raise_on_fail=True)
58 return fallback_url
27@override_settings(APPEND_SLASH=True)
28def test_redirect_with_append_slash(self):
29 Redirect.objects.create(site=self.site, old_path='/initial/', new_path='/new_target/')
30 response = self.client.get('/initial')
31 self.assertRedirects(response, '/new_target/', status_code=301, target_status_code=404)
744def __init__(self, redirect_to):
745 super(HttpResponsePermanentRedirect, self).__init__()
746 self['Location'] = iri_to_uri(redirect_to)

Related snippets