f you are just trying to redirect to an absolute URL stored in Redis, your code should work provided the string is clean.
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m58s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m58s
A robust way to ensure it's treated as a simple URL might involve using Django's HttpResponseRedirect directly instead of the redirect shortcut:
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import redis
|
import redis
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.shortcuts import redirect
|
|
||||||
|
|
||||||
r = redis.Redis(
|
r = redis.Redis(
|
||||||
host='django-redis-svc',
|
host='django-redis-svc',
|
||||||
@@ -36,6 +36,6 @@ def display_key(request,key):
|
|||||||
def redirect_to_key(request,key):
|
def redirect_to_key(request,key):
|
||||||
value = r.get(key)
|
value = r.get(key)
|
||||||
print(value)
|
print(value)
|
||||||
value_extracted = str(value.decode())
|
value_extracted = str(value.decode('utf-8'))
|
||||||
print(value_extracted)
|
print(value_extracted)
|
||||||
return redirect(str(value_extracted))
|
return HttpResponseRedirect(value_extracted)
|
||||||
Reference in New Issue
Block a user