3๐
Try this:
Move the static folder from the project root into the particular App directory. Do that for all the apps you create as Django uses django.contrib.staticfiles which takes care of all static files in your project. As referenced here
2๐
make sure you have the file base.css
in the css
folder then for some weird reasons try using double-quotes.
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
- [Django]-Insert pandas data frame into Postgres
- [Django]-Django crispy forms โ Set label text for multiple fields
- [Django]-Django extends different base templates
- [Django]-Django: export current queryset to csv by button click in browser
2๐
In Django, there is one root static directory which lives under the project directory (at the same level of apps directories),in addition to this, there are other static directories live under Apps directories, and for each app which needs to use static files, A static directory should be created under it to host its particular static staff, so make sure to create static directory under each app so its views and templates can access them and run collectstatic whenever new static staff is added to static directories.
make sure in Setting file that STATIC_DIRC = [ "BASE-DIR /[App-Name].static"] for each app has static directory, dont include the root static directory otherwise Django will throws an error
I have faced this issue and spent few hours looking for solution which I finally got and the credit goes to Asiak answer (mentioned above)
- [Django]-What are reasons for not using Django Admin with Django Rest Framework
- [Django]-What does 'serializer.initial_data' mean?
- [Django]-New-line character seen in unquoted field
- [Django]-Switch to Django Custom User Model, Groups and Permissions
- [Django]-Django Rest Framework error: {"user":["This field is required."]
0๐
I had the same issue for a while. As you have explained, your code is alright and files are placed in the right directories. However, what I found out to be my issue was not including the following in the app/urls.py
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# ... the rest of your URLconf goes here ...
]+ static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)
For a better explanation check out the documentation django-staticfiles documentation
- [Django]-Assigning a proxy model instance to foreign key
- [Django]-How do I know if jobs have been/are performing? โ Crontab
0๐
"GET /static/css/base.css HTTP/1.1" 404 1660
First of all check out if base.css is placed in css directory.
- [Django]-How do I populate a hidden required field in django forms?
- [Django]-Forms generated through admin in Django
- [Django]-Django โ WSGI script cannot be loaded as Python module