简体   繁体   中英

gentelella for django doesn't recognize changes on custom.css

I am trying to apply gentelella bootstrap template for django, so I copied the app directory into my own django project. I am using some of-the-box html templates, so I copy them to the templates directory of the proper application, but I keep all static content on the app directory. The problem is when I modify the app/static/build/css/custom.css file, because I the html files don't reflect the change.

In this case, I added the new class yellow to the custom.css file, and I added such class to some objects in the index2.html file, but the color of the text didn't change.

This the django project directory tree:

├── 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

This is the custom.css file. The yellow class is the one I added.

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

This is the index2.html file, where I assign the new yellow class to an object.

  <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>

and this is the base_site.html file, where the custom.css file is included:

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

I don't know why, but my html's fail to recognize any change I make to custom.css .

In Django 1.10 and above just {% load static %} in the top of your template.

Then

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

and make sure you are serving the static files in your development server.

# Attractora/Attractora/urls.py
if settings.DEBUG:
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns
    urlpatterns += staticfiles_urlpatterns()

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