2👍
Since you are using customised path, why dont you tell the django where to find it.. use this in settings and it shall work fine.
option 1:
in case you are serious about preserving your file structure
#settings.py
STATICFILES_DIRS = (
...
os.path.join(BASE_DIR, 'app/src/static') # build appropriate path
)
UPDATE:
option 2:
move the static folder to where manage.py
exists or into the child of app.
example:
...manage.py
...static
...app/
or
...manage.py
...app/static
1👍
STATIC_URL
only control the prefix of static files URL (i.e web address). It doesn’t control their physical location on disk.
Move your static files from app_name/src/static/
to app_name/static/
and that should fix it
Edit:
If you want to keep directory structure as it is, you have couple of options
- Manually add your static file directories to
STATICFILES_DIRS
- Create a class that inherit from
django.contrib.staticfiles.finders.AppDirectoriesFinder
and set the source_dir attribute
from django.contrib.staticfiles.finders import AppDirectoriesFinder
class MyAppDirFinder(AppDirectoriesFinder):
source_dir = "src/static"
Then you can add your class to STATICFILES_FINDERS
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'myapp.finders.MyAppDirFinder',
]
Reference: https://docs.djangoproject.com/en/1.11/ref/settings/#static-files
- [Django]-Django static templatetag not displaying SVG
- [Django]-Django: how to map the results of a raw sql query to model instances in admin list view?
- [Django]-Why shouldn’t I add additional profile fields directly to my django.contrib.auth.models.User table?
0👍
Indside static folder you need to create a folder with app name
Now your folder structure is
|-------- src
|------------ static
|---------------- css
|-------------------- bootstrap
|------------------------ bootstrap.min.css
Change it to
|-------- src
|------------ static
|-------------------app_name
|--------------------------- css
|-------------------- ----------bootstrap
|---------------------------------------- bootstrap.min.css
- [Django]-Django query ordered objects given position
- [Django]-Django Rest Framework + AngularJS: Correct way for CSRF Protection?
0👍
add
STATICFILES_DIRS=(os.path.join(BASE_DIR, '../frontend'),)
or
STATICFILES_DIRS=()
in your settings.
Then it should work.
Took me a long time to find this.
- [Django]-Upgrading to django 1.11 many to many column not found
- [Django]-DRF "field is required" error on POST request?
- [Django]-Urls in Django 1.7 when the Url Contains spaces
- [Django]-Django Deployment Process to Webfaction.com
- [Django]-How to debug patched method with unittest.mock