Monday, March 31, 2025

Re: Problem with static files inDjango-Oscar

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.


On Sunday, March 30, 2025 at 9:09:00 PM UTC+1 Hugo Chavar wrote:
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!

Hugo

On 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.

Sunday, March 30, 2025

Re: Problem with static files inDjango-Oscar

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!

Hugo

On 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/af12ddc1-70c5-4a4c-9b68-8ff7c5947c07n%40googlegroups.com.

Re: Problem with static files inDjango-Oscar

If you Facing static file issue in your Django project.
You should use Base_Dir include OS

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'), 

Because you run the Project Locally.
I hope this will help you 
On Monday, 31 March 2025 at 00:44:32 UTC+5 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/03af6144-c04f-419f-aa36-e54792628aa1n%40googlegroups.com.

Re: Problem with static files inDjango-Oscar

Try installing Pillow if you didn't

On Sunday, March 30, 2025 at 10: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/1277eece-f0c8-4d8f-8ba1-a31bfad0e71cn%40googlegroups.com.

Problem with static files inDjango-Oscar

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/b62d7840-8b4a-4835-bc95-434bb40aca2an%40googlegroups.com.