How to host a Django project in a subpath?

后端 未结 2 444
不知归路
不知归路 2021-01-12 13:25

I am building an API with Django REST framework which is served via Gunicorn and Nginx. The project \"exampleproject\" has to run at a subpath such as: https://100.100.100.1

2条回答
  •  佛祖请我去吃肉
    2021-01-12 14:14

    I found here that one needs to add the following setting to Django's configuration in settings.py:

    FORCE_SCRIPT_NAME = '/exampleproject'
    

    This seems to rewrite all paths for nested resources.

提交回复
热议问题