Django Two ways to add static files of must read
- 2020-06-12 09:50:34
- OfStack
Django adds static files in two ways:
First, add the path to the static file in the ES4en.py configuration file:
STATICFILES_DIRS = [os.path.join (BASE_DIR, "statics"),] statices name of the folder you created to hold static files
Then make a reference.
1, html file through /static/ resource name, you can access to the resource
2, html file header {% load staticfiles %}, path {% static 'css/ xx. css' %} #static equals STATIC_URL = '/static/' in configuration file, can be modified as needed, it doesn't make much sense.