Python Forum
[Django] css file is not applying to the page
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Django] css file is not applying to the page
#1
I have a link to a css file in my html but it's not applying to the site. There are no errors and when I go to inspect -> sources the css file is not there, so I see the problem, but I don't see the solution. Thanks in advance for any help.
This is the base html file that loads in the css.
{% load static %}

<link rel="'stylesheet" type="text/css" href="{% static 'polls/styles.css' %}">
<!DOCTYPE html>
<html lang="en">
.
.
.
This is the css file in case you want to see it
li a {
    color: green;
}

body {
    
}

.question-display {
    border-color: black;
    border-width: 5px;
    position: center;
}

.question-link {
    
}
.
.
.
This is the line of code I have in settings STATIC_URL = '/static/'.
Then I have 'django.contrib.staticfiles' under INSTALLED_APPS in settings.
Reply
#2
If your on an apache2 web server, you may need to setup an alias for the static folder.
Or you may need to do the collect static command. I don't remember the command.
Here is how mine is setup. The static folder resides in the django root folder.
I did not see tags for and code other than python.
{% load static %}
<!DOCTYPE html>
<html lang="en" dir="ltr">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>{% block title %}{% endblock title %}</title>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
        <link rel="stylesheet" href="{% static 'css/homepages/home.css' %}">
        <link href="https://fonts.googleapis.com/css?family=Peralta&display=swap" rel="stylesheet">
        <link rel="stylesheet" href="{% static 'css/all.css' %}">
    </head>
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  <title> django page title dynamic and other field (not working) lemonred 1 2,072 Nov-04-2021, 08:50 PM
Last Post: lemonred
  creating an exe file for a python django project Sanjish 0 2,586 Dec-27-2020, 07:33 AM
Last Post: Sanjish
  use Xpath in Python :: libxml2 for a page-to-page skip-setting apollo 2 3,579 Mar-19-2020, 06:13 PM
Last Post: apollo
  upload big file in Django with process bar and i get error : MemoryError ma_norouzifar 3 4,337 Aug-06-2019, 06:57 AM
Last Post: fishhook
  Django Two blocks of dynamic content on one page iFunKtion 5 4,340 Jul-04-2019, 02:31 AM
Last Post: noisefloor
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,246 Jun-30-2019, 12:21 AM
Last Post: scidam
  Sorting getting off, when I switch page Django 1.11 m0ntecr1st0 0 1,957 Feb-12-2019, 06:40 PM
Last Post: m0ntecr1st0
  Open Sqlite database file directly in django sourabhjaiswal92 0 2,923 May-22-2018, 05:55 AM
Last Post: sourabhjaiswal92
  Django-cms link to a page Alkatron 4 8,220 Apr-06-2018, 10:58 AM
Last Post: Alkatron
  How do I make a Django model from a tab-delimited data file? newbietostuff 0 2,501 Jan-09-2018, 02:44 AM
Last Post: newbietostuff

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020