Django: how to make STATIC_URL empty?

后端 未结 2 660
醉话见心
醉话见心 2021-01-24 06:56

Yep, I want it to work like in Flask framework - there I could set parameters like this:

static_folder=os.getcwd()+\"/static/\", static_url_path=\"\"

<
2条回答
  •  暖寄归人
    2021-01-24 07:37

    I believe this is not supported out of the box. Off the top of my head, one way to do it would be with a special 404 handler that, having failed to match against any of the defined URLs, treats the request as a request for a static resource. This would be reasonably easy to do in the development environment but significantly more difficult when nginx, Apache, and/or gunicorn get involved.

    In other words, don't do this. Nest your statics (or put them on a different sub domain) but don't mix the URL hierarchy in this way.

提交回复
热议问题