如何在 Django 中设置基本 URL [英] How to set base URL in Django
问题描述
我想从 https://www.example.com/someuri/ 这样我就可以在 https://www.example.com/someuri/admin/.我可以看到登录窗口,但是当我登录时,我被重定向到 https://www.example.com/admin/.
I would like to run Django from location https://www.example.com/someuri/ so that I have the admin interface at https://www.example.com/someuri/admin/. I can see the login window but when I log in I get redirected to https://www.example.com/admin/.
在哪里可以将 Django 的基本 URL 设置为 https://www.example.com/someuri/?我尝试使用 BASE_URL 但没有运气.
Where can I set the base URL of Django to https://www.example.com/someuri/? I tried with BASE_URL but with no luck.
推荐答案
@AgileDeveloper 的回答对于管理员的那一种情况是完全正确的.但是,是否希望为所有 URL 设置这种方式?如果是这样,也许你应该这样做
@AgileDeveloper's answer is completely correct for that one off case of admin. However, is the desire to set it this way for all URLs? If so, perhaps you should do something like this
from django.conf.urls import include, url
from . import views
urlpatterns = [
url(r'^someuri/', include([
url(r'^admin/', include(admin.site.urls) ),
url(r'^other/$', views.other)
])),
]
这篇关于如何在 Django 中设置基本 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!