Check STATICFILES_DIRS
Since you are running locally, you need to add:
python
CopyEdit
STATICFILES_DIRS = [BASE_DIR / "static"]
This tells Django where to look for static files in development mode.
2. Use runserver With --insecure (For Debugging)
Try running the development server with:
bash
CopyEdit
python manage.py runserver --insecure
This forces Django to serve static files even if DEBUG = False.
3. Check If Static Files Are Collected Properly
Run:
bash
CopyEdit
python manage.py collectstatic --noinput
Then check if all static files are correctly placed inside STATIC_ROOT.
4. Manually Serve Static Files (Development Mode Only)
If it's still not working, add this to urls.py (only for local testing!):
python
CopyEdit
from django.conf import settings
from django.conf.urls.static import static
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
5. Check If Static Files Exist and Are Reachable
Run the following command to check what static files Django can find:
bash
CopyEdit
python manage.py findstatic main.css
If Django can't find the file, then it's not stored where it expects.
6. Confirm File Paths in Templates
Ensure your paths are correct. Try:
html
CopyEdit
<link href="{% static 'css/main.css' %}" rel="stylesheet">
If your main.css file is inside static/css/, then update your path accordingly.
7. Try Restarting the Server
Sometimes, simply stopping and restarting the Django server helps:
bash
CopyEdit
CTRL + C # Stop the server
python manage.py runserver # Start it again
8. Check Browser Dev Tools
Open your browser's Developer Console (F12) → Network → Static Files and check the request URL for errors.
Hi Ewa looks like you need one more setting for development:STATICFILES_DIRS = [BASE_DIR / 'static_files', # or whatever directory contains your static files
]If that doesn't work, share your urls.py
Maybe it worked for a small project because you have DEBUG = False in that case.
Let me know if this worked!
HugoOn Sunday, March 30, 2025 at 4:44:32 PM UTC-3 Szawunia wrote:Hi everybody,I have problem with my static files in my Django project, running local. Actually Django-Oscar, but settings files is Django. There are not founded (404 error). I have all my static files in my project directory (where 'manage.py' is).My settings:STATIC_URL = 'static/'
STATIC_ROOT = BASE_DIR / 'static'
In my templates:
{% load static %}
<link href="{% static "main.css" %}" rel="stylesheet">
<link rel="shortcut icon" href="{% static "logo3.gif" %}" />
I stuck with that problem. Earlier in my Django simple project, all was ok. So my settings should be right.
Any help will be appreaciate. Or any idea how to check, in simple way, what is wrong with my static loading
With all the best
Ewa
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/django-users/b1736bce-b244-41f4-b7cc-a3cd8038df76n%40googlegroups.com.