简体   繁体   中英

How to configure settings in Django when realative reference of static files don't contain a 'static'?

I'm a newbee to html/js/css.

Now I have a big frontend that use realative reference of static files that don't contain a 'static' prefix.

在此处输入图片说明

However Django need a STATIC_URL definition in settings.py, default is "/static/".

Then the real request url is "/demo/faces/male/16.jpg", but the url django expected is "/static/demo/faces/male/16.jpg"

在此处输入图片说明

It's really a big frontend maintained by other guys, I don't want to modify it. Is there a method to remove the 'static' requirement?

See this . It says "In addition to using a static/ directory inside your apps, you can define a list of directories (STATICFILES_DIRS) in your settings file where Django will also look for static files."

The example that they give puts static in the specification of the additional directory, but that appears to be inessential. So you would just list your /demo/faces/male and /demo/faces/female/ directories.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM