R
R
rbs972021-07-08 15:11:02
Django
rbs97, 2021-07-08 15:11:02

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

1 answer(s)
N
Nikita Mokhovikov, 2021-07-12
@rbs97

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 )

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

urls.py
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)

See here for more details

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question