Beef
March 17, 2025, 7:23am
1
Hi, guys! I downloaded the project from Github and faced the problem, that my styles, scripts, images aren’t applied. I get errors of the following kind:
Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Refused to execute script from 'http://127.0.0.1:8000/static/assets/vendor/chart.js/chart.umd.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Structure of the project:
STATIC_URL setting:
STATIC_URL = '/static/'
example of dynamic links in base.html:
<!-- Vendor CSS Files -->
<link href="{% static 'assets/vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
<link href="{% static 'assets/vendor/bootstrap-icons/bootstrap-icons.css' %}" rel="stylesheet">
<link href="{% static 'assets/vendor/boxicons/css/boxicons.min.css' %}" rel="stylesheet">
<link href="{% static 'assets/vendor/quill/quill.snow.css' %}" rel="stylesheet">
<link href="{% static 'assets/vendor/quill/quill.bubble.css' %}" rel="stylesheet">
<link href="{% static 'assets/vendor/remixicon/remixicon.css' %}" rel="stylesheet">
<link href="{% static 'assets/vendor/simple-datatables/style.css' %}" rel="stylesheet">
<!-- Template Main CSS File -->
<link href="{% static 'assets/css/style.css' %}" rel="stylesheet">
<link href="{% static 'assets/css/dark-mode.css' %}" rel="stylesheet">
I would be very grateful if you can help solve the problem
boxed
March 17, 2025, 7:35am
2
Try going to that url in your browser. I’m going to bet it’s a 404 page.
I’m going to just guess you should install whitenoise.
Beef
March 17, 2025, 8:58am
4
I tried to install whitenoise and also specified it in settings.py in MIDDLEWARE 'whitenoise.middleware.WhiteNoiseMiddleware'
Unfortunately, no positive results, still getting the error “Not found” (404).
abbasj
March 17, 2025, 9:28am
5
Try removing the trailing slash so that you have:
STATIC_URL = “static/”
abbasj
March 17, 2025, 10:44am
7
I had a similar issue a few days ago and it was related to my JS files.
Check your chart.umd.js file because I think something is wrong in that file.
You can also share it and I’ll take a look
Beef
March 17, 2025, 11:42am
8
here is the link to the chart.umd.js
thansk so much
abbasj
March 17, 2025, 12:05pm
9
Please update the question and add the code in .
Beef
March 17, 2025, 12:25pm
10
i am not able to add the code in it, because body is limited to 32000 characters My chart.umd.js has 207000…
Let’s take a step back for a moment and check a couple of fundamentals.
Is this your development environment using runserver, or your production environment using something like gunicorn or uwsgi?
Either way, your logs (or console in the case of runsever) should show the 404 codes along with the URL(s) being requested.
Please post all of the URLs being requested that are resulting in a 404.
From your settings.py file, please post the following settings:
INSTALLED_APPS
MIDDLEWARE
DEBUG
STATICFILES_DIRS
Beef
March 17, 2025, 1:15pm
12
Yes, it’s my development environment using runserver.
started my server:
opened http://127.0.0.1:8000/ , so my login page opened:
Logged in after entering username and password, base page opened:
The same problems occur, when i visit all other pages of the application.
dashboard:
inventory:
create new item:
and so on..
From settings.py file:
INSTALLED_APPS = [
'myapp',
'django_celery_beat',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django_http_referrer_policy.middleware.ReferrerPolicyMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'csp.middleware.CSPMiddleware',
]
regarding DEBUG i have such snippet:
# get debug modus from env
DEBUG = os.environ.get('DEBUG', 'False').lower() in ['true']
I do not have STATICFILES_DIRS
Let my know if if any additional information is needed, thanks.
For testing purposes, set DEBUG = True and try it again.
1 Like
Beef
March 17, 2025, 1:53pm
14
It works, I appreciate it, thanks so much
Just keep in mind that this is for testing and development purposes only. When you’re ready to deploy this to a production environment, you will need to take other steps.
1 Like