How to set base URL in Django

后端 未结 4 585
故里飘歌
故里飘歌 2021-01-04 09:30

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 w

4条回答
  •  爱一瞬间的悲伤
    2021-01-04 10:07

    @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)
        ])),
    ]
    

提交回复
热议问题