[Answered ]-CSS is not loading in Django Admin Panel App?

0👍

Thanks, Guys I added the following in my setting.py file, and now it’s working fine:

import mimetypes
mimetypes.add_type("text/css", ".css", True)

1👍

Assuming you have DEBUG=False in settings.py, you need to manually serve static files. Note that this is not recommended for production – you should serve static files using your web server such as apache on nginx. Also note that django will do this automatically, if you have DEBUG=True.

urls.py:

import re

from django.urls import re_path
from django.conf import settings
from django.views.static import serve

urlpatterns = [
    ...
    re_path(r'^%s(?P<path>.*)$' % re.escape(settings.STATIC_URL.lstrip('/')), serve, {"document_root": settings.STATIC_ROOT}),
]

0👍

try this might help

from django.conf.urls import url
from django.views.static import serve
from django.conf.urls.static import static
from django.conf import settings


    url(r'^media/(?P<path>.*)$', serve,{'document_root': settings.MEDIA_ROOT}),
    url(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}),
]
if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

or if it still does not work for you
set debug=false
thane python manage.py collectstatic after creating a static cdn folder and paste you localhost path in allowed host section and then tell us if it still not loading admin css

Leave a comment