Answer the question
In order to leave comments, you need to log in
Django admin panel styles not working?
Good afternoon!
Raised a Django application in a Docker container. When I try to log in to the admin panel in the logs, I see the following entries:
Internal Server Error: /static/admin/css/base.css
Internal Server Error: /static/admin/css/nav_sidebar.css
Internal Server Error: /static/admin/ css/responsive.css
And styles are not displayed in the panel itself.
Has anyone experienced this behavior and can suggest a way to fix this problem?
settings.py settings:
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
#BASE_DIR / "static",
]
urls.py settings:
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from django.views.generic import RedirectView
urlpatterns = [
path('admin/', admin.site.urls),
# path('accounts/', include('accounts.urls')),
path('home/', include('home.urls'))
] + static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS)
Answer the question
In order to leave comments, you need to log in
From memory, in settings.py you need to put STATIC_ROOT instead of STATICFILES_DIRS and do python manage.py collectstatic ( it seems to be called that )
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
urlpatterns = [
path('admin/', admin.site.urls),
# path('accounts/', include('accounts.urls')),
path('home/', include('home.urls'))
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question