tarp20
tarp20

Reputation: 695

Cant read static file CSS in Django Project

Cant read static file CSS in Django Project my html file looks
where is a mistake

{% load static %}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{% block title %} {% endblock %}</title>
    <link rel = "stylesheet" href="{% static '/css/bootstrap.min.css' %}">
    <link rel = "stylesheet" href="{% static '/css/style.css' %}">

    <script scr = '{% static 'js/bootstrap.min.js' %}'></script>
</head>
<body class="bg-blue">

  <div class="container">
      <div сlass="row">
          <div class="col-lg-4 col-lg-4">
              <br/>
              <br/>
              <br/>
              <div class="panel panel-body">
                  <div class="panel-body">
                      <h3 class="text-center text-uppercase"><b>{% block heading %}{% endblock %}</b></h3>
                      <br/>
                      {% block content %}{% endblock %}
                  </div>
              </div>
          </div>
      </div>
  </div>

</body>
</html>

settings.py

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR,'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'TarFoodApp',
    'oauth2_provider',
    'social_django',
    'rest_framework_social_oauth2',
]

where is a mistake ? in what dir I have to put my static file , now its in project root

if needed more code of another files please tell me .

Upvotes: 0

Views: 51

Answers (2)

Sulav Sapkota
Sulav Sapkota

Reputation: 86

First Mistake : <script scr = '{% static 'js/bootstrap.min.js' %}'> Change that to:

Though this mistake doesn't necessarily affect the css the real fix might be :

  1. Make sure static folder is in the same folder of your app.

Upvotes: 0

GAEfan
GAEfan

Reputation: 11360

Here is the first mistake I found. You are nesting single quotes, and should be src, not scr:

<script scr = '{% static 'js/bootstrap.min.js' %}'></script>

Try:

<script src = "{% static 'js/bootstrap.min.js' %}"></script>

Upvotes: 1

Related Questions