【发布时间】:2021-09-10 18:52:31
【问题描述】:
我正在尝试将用户重定向到一个 URl,但它正在将我重定向到一个不正确的 url。
views.py:
def redirect_shortner(request):
return redirect('www.google.com')
url.py:
urlpatterns = [
path('', redirect_shortner, name='redirect_shortner'),
]
代码对我来说似乎是正确的,但用户被错误地重定向到当前 url 附加指定 url 的 url,即当 http://127.0.0.1:8000/ 是当前 url 时,用户被重定向到 http://127.0.0.1:8000/www.google.com。
【问题讨论】:
-
你能尝试重定向这个吗?
https://www.google.com/
标签: django django-rest-framework django-views django-urls