M
M
MAXIMMMMMKA2021-11-29 21:53:13
Django
MAXIMMMMMKA, 2021-11-29 21:53:13

Django not applying css file 404 error??

I did everything as in the Django documentation, but nothing works

settings
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, "static")
STATICFILES_DIRS = os.path.join(BASE_DIR, 'static')

URL

urlpatterns = [
path('grappelli/', include('grappelli.urls')),
path('admin/', admin.site.urls),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

Html
{% load static %}
well and further

where to dig???

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexanderzanin, 2021-11-29
@alexanderzanin

If you are on a local computer under Windows, then it is easier to copy the path to the folder

STATIC_URL = '/static/'
STATICFILES_DIRS = [
     os.path.join('C:\PythonProject\name.project\app\static'),
 ]

On the server under nginx and the static configuration in the nginx config.
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

And it's even easier to understand these paths, just print them out with print, these are ordinary variables that will be printed to the console when you run django.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question