Django don't load css

144 views
Skip to first unread message

Jovana Andjelkovic

unread,
Dec 15, 2014, 1:13:03 AM12/15/14
to django...@googlegroups.com
I am trying to run a site on Django development server but my css don't load. When I open dev tools in Chrome I see in network that css is loaded as text/plain and not as text/css.My link is good,because when I open it,it opens my css file.And my admin site don't have css also,and that can't be my mistake because I didn't do anything with it! As soon as I change something in css in dev tools css starts working but as soon as I reload the page it is gone!

Mario Gudelj

unread,
Dec 15, 2014, 7:23:22 AM12/15/14
to django...@googlegroups.com

You may have an error in your css file if the link isn't 404ring when you look at your console or the chrome tab...

On 15/12/2014 1:36 pm, "Jovana Andjelkovic" <j.andje...@gmail.com> wrote:
I am trying to run a site on Django development server but my css don't load. When I open dev tools in Chrome I see in network that css is loaded as text/plain and not as text/css.My link is good,because when I open it,it opens my css file.And my admin site don't have css also,and that can't be my mistake because I didn't do anything with it! As soon as I change something in css in dev tools css starts working but as soon as I reload the page it is gone!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e5a23d51-5866-42d0-9e9e-2e69a8c3c340%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jovana Andjelkovic

unread,
Dec 15, 2014, 9:44:11 AM12/15/14
to django...@googlegroups.com
It is not 404,it is 304 NOT MODIFIED,and it load it as text/plain...

Jovana Andjelkovic

unread,
Dec 15, 2014, 6:57:02 PM12/15/14
to django...@googlegroups.com
This is my html head with css link:
<head>
<title>Rango</title>
<link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}"/>
</head>
This is settings.py:
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
TEMPLATE_PATH = os.path.join(BASE_DIR, 'templates')
STATIC_PATH = os.path.join(BASE_DIR, 'static')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATIC_ROOT = os.path.join(BASE_DIR, 'root/static')

DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rango',
)
MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'tango_with_django.urls'
WSGI_APPLICATION = 'tango_with_django.wsgi.application'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True

STATIC_URL = '/static/'
STATICFILES_DIRS = (
    STATIC_PATH,
    )
TEMPLATE_DIRS = [
    TEMPLATE_PATH,
]
MEDIA_URL = '/media/'




Héctor Urbina

unread,
Dec 15, 2014, 8:22:20 PM12/15/14
to django...@googlegroups.com
somecallitblues didn't say that it's 404 error, he said that you could have an error (some typo) in your base.css... perhaps you should check it with some css validator.

Jovana Andjelkovic

unread,
Dec 15, 2014, 9:38:50 PM12/15/14
to django...@googlegroups.com
Sorry,I didn't understand him :) 
I check css with css validator and it didn't find any errors.It is simple css file,just to check if everithing is working.
I don't understand why css is not recognised as text/css,but as text/plain.
Thank you for your answer...

Héctor Urbina

unread,
Dec 16, 2014, 11:51:46 AM12/16/14
to django...@googlegroups.com
Vadims Briksins seems to have had the same problem in Django 1.6.4. You could contact him and ask him if and how he resolved it.

Jovana Andjelkovic

unread,
Dec 16, 2014, 12:51:57 PM12/16/14
to django...@googlegroups.com
Thank you,I will.I'll let you know if I solve my problem...

Jovana Andjelkovic

unread,
Dec 16, 2014, 4:30:13 PM12/16/14
to django...@googlegroups.com
Thank you very much,Vadims helped me.
The problem wasn't related to the Django,I installed NuSphere and it changed values in os registry.
In regedit.exe I changed all css to text/css,restarted PC and css is now working fine...
Here is registry fix,if someone who is having this type of problem don't want to change registry manualy:
Reply all
Reply to author
Forward
0 new messages