简体   繁体   中英

Static css file not loading in Django admin

I'm trying to load my own css file to replace base.css in order to customize Django Admin

{% extends "admin/base.html" %}
{% load static %}
{% block title %}VSPM{% endblock %}

{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('Django administration') }}</a></h1>
{% endblock %}

{% block stylesheet %}{% static "admin/css/theme.min.css" %}{% endblock %}

{% block nav-global %}{% endblock %}

But the css file isn't loading in Django admin. What am I doing wrong?

{% block extrastyle %}{% static "admin/css/theme.min.css" %}{% endblock %}

更改您的块名称并尝试

  1. Go to your project.
  2. Copy this folder /virualent_path//lib/python3.6/site-packages/django/contrib/admin/static/admin to 'static' folder of your project.
  3. Add this string to the settings.py: STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
  4. Then run this command: python3.6 manage.py collectstatic

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM