django的gentelella无法识别custom.css上的更改

问题描述 投票:0回答:1

我正在尝试为django应用gentelella bootstrap模板,所以我将app目录复制到我自己的django项目中。我正在使用一些盒子的html模板,所以我将它们复制到正确应用程序的templates目录中,但我将所有静态内容保存在app目录中。问题是当我修改app/static/build/css/custom.css文件时,因为我的html文件没有反映出更改。

在这种情况下,我将新类yellow添加到custom.css文件中,并将此类添加到index2.html文件中的某些对象,但文本的颜色没有改变。

这个django项目目录树:

├── Attractora
│   ├── ActorsManagerApp
│   │   ├── __init__.py
│   │   ├── admin.py
│   │   ├── apps.py
│   │   ├── migrations
│   │   ├── models.py
│   │   ├── templates
│   │   │   └── ActorsManagerApp
│   │   │       ├── index2.html
│   │   │       └── profile.html
│   │   ├── tests.py
│   │   ├── urls.py
│   │   └── views.py
│   ├── Attractora
│   │   ├── __init__.py
│   │   ├── settings.py
│   │   ├── urls.py    
│   │   └── wsgi.py
│   ├── app
│   │   ├── __init__.py
│   │   ├── __init__.pycn-36.pyc
│   │   ├── admin.py
│   │   ├── admin.pyc
│   │   ├── apps.py
│   │   ├── migrations
│   │   ├── models.py
│   │   ├── static
│   │   │   └── build
│   │   │       └── css
│   │   │           └── custom.css
│   │   ├── templates
│   │   │   └── app
│   │   │       └── base_site.html

这是custom.css文件。 yellow类是我添加的类。

.blue {
    color: #3498DB
}
.purple {
    color: #9B59B6
}
.green {
    color: #1ABB9C 
}
.aero {
    color: #9CC2CB
}
.red {
    color: #E74C3C
}
.yellow {
    color: #F1C40F
}

这是index2.html文件,我将新的yellow类分配给一个对象。

  <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
      <div class="tile-stats">
        <div class="icon"><i class="fa fa-info-circle yellow"></i></div>
        <div class="count yellow">179</div>
        <h3><span class="yellow">Attention</span></h3>
        <p>Tasks about to start or finish.</p>
      </div>
    </div>
    <div class="animated flipInY col-lg-3 col-md-3 col-sm-6 col-xs-12">
      <div class="tile-stats">
        <div class="icon"><i class="fa fa-warning red"></i></div>
        <div class="count red">179</div>
        <h3><span class="red">Late</span></h3>
        <p>Tasks already due to start or finish.</p>
      </div>
    </div>

这是base_site.html文件,其中包含custom.css文件:

    <!-- Custom Theme Style -->
    <link href="/static/build/css/custom.css" rel="stylesheet">

我不知道为什么,但是我的html没有认识到我对custom.css所做的任何改变。

python html css django gentelella
1个回答
0
投票

In Django 1.10及以上只是模板顶部的{% load static %}

然后

<link href="{% static 'build/css/custom.css' %}" rel="stylesheet">

并确保您在开发服务器中提供静态文件。

# Attractora/Attractora/urls.py
if settings.DEBUG:
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns
    urlpatterns += staticfiles_urlpatterns()
© www.soinside.com 2019 - 2024. All rights reserved.