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}),
]
- [Answered ]-Why does Django throw a warning when loading my URLconf?
- [Answered ]-Where to store color information in a web application?
- [Answered ]-Best practices for DVCS and reusable Django apps
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
- [Answered ]-A pip install to include template/static files in actually app directory (not just in the site-packages dir)
- [Answered ]-How will I add css with Django Ckeditor?
- [Answered ]-Django objects queryset
- [Answered ]-JQuery datepicker localization in django admin 1.7 + django-grappelli 2.6.1
- [Answered ]-Inline edit all ForeignKey related to a model[django admin]
Source:stackexchange.com