Questions tagged [django-static]

113 questions
141
votes
4 answers

Differences between STATICFILES_DIR, STATIC_ROOT and MEDIA_ROOT

What are the differences of these three static url? I am not sure if I am right, I am using the MEDIA_ROOT to store my uploaded photos (via models.ImageField()) However, I created a JS script to my admin and in admin.py. I defined the media as…
dev-jim
  • 2,404
  • 6
  • 35
  • 61
62
votes
9 answers

How to refer to static files in my css files?

I have a reference inside my CSS file that refers to a static image: #logo { background: url('/static/logo.png') } This works just fine on my dev machine but not on my production environment since the url should be…
the_drow
  • 18,571
  • 25
  • 126
  • 193
59
votes
10 answers

The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting

I'm using Django 1.7. When deploying my site to a Production server and running collectstatic, I get following error message: django.core.exceptions.ImproperlyConfigured: The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting I…
SaeX
  • 17,240
  • 16
  • 77
  • 97
44
votes
10 answers

Invalid block tag: 'static'

Server returned TemplateSyntaxError at / Invalid block tag: 'static' on this line: . The whold html file is like this (it's an html file {% include %}ed by another one): {% load staticfiles %}
Yan Yang
  • 1,804
  • 2
  • 15
  • 37
19
votes
2 answers

{% load static %} and {% load staticfiles %}: which is preferred?

I'm not sure what the difference is, it seems like both of them are working. I googled around, and seems like they are pretty much same thing. Just out of curiosity, which one do people use in the field? I read that but still don't know when to…
user5659156
18
votes
2 answers

Static files won't load when out of debug in Django

I'm creating a Django project. I just tried taking the project out of debug, DEBUG = False and for some reason all my static files do not show up. They give an error code of 500. How do i fix this? some of settings.py: DEBUG = True TEMPLATE_DEBUG =…
Nachshon Schwartz
  • 15,289
  • 20
  • 59
  • 98
14
votes
3 answers

Django static files won't load

i'm a Django newbie working on my first project and having a problem with static files. I have created a simple auth system using django.contrib.auth consisting of two templates: mysite/templates/index.html and…
JimJay
  • 349
  • 2
  • 8
  • 17
8
votes
1 answer

Referencing image in CSS with relative path doesn't work in Django

I am using Django 1.3 with built-in static app. My static folder structure is like this: static/ css/ main.css img/ js/ So I tried to reference images under static/css/img/ folder from CSS like…
Yifu
  • 265
  • 1
  • 4
  • 8
5
votes
1 answer

apache server cant find static files in Django project

I'm trying to upload my code on an apache server using mod_python. I have tried a lot but the server is not able to access my static files (all my images, js and css). Here are my Virtualhost settings: ServerName…
user_2000
  • 1,103
  • 3
  • 14
  • 26
4
votes
1 answer

Why isn't Django serving staticfiles in production?

I am wondering the reason why Django does not serve the statifiles in production, when DEGUB = False. STATICFILES_DIRS We specify STATICFILES_DIRS to tell Django where to look for staticfiles that are tied up to a specified app. STATIC_ROOT We…
4
votes
1 answer

How to use node modules with Django?

I wish to use date-fns in my django project but not entirely sure how to proceed - I cannot rely on a CDN and need to somehow get it installed. I have run npm init in my root folder followed by npm install date-fns. This generated a node_modules…
erikvm
  • 858
  • 10
  • 30
4
votes
1 answer

What is the use of {% load static %}?

I am doing the django tutorial on realpython https://realpython.com/get-started-with-django-1/ In one of the templates they add {% load static %} to load the static files for an app. In the same template they also load an image like this
FAM_Maurice
  • 363
  • 3
  • 10
4
votes
2 answers

is there a way to add new skin in django-ckeditor?

I'm trying to add new skin in django-ckeditor but its doesnt work and it shows a blank screen in django-admin I have installed the kama skin and extracted in static\ckeditor\ckeditor\skins\kama but doesnt seem to work. Below im showing my ckeditor…
4
votes
3 answers

Serve different Static files on devel and production in Django

I have a production and local DJANGO development environment. To push things to production we have a deployer which minifies and gzips all CSS and JS files. To serve them on production I need to call them like
4
votes
1 answer

Make Django compress with {% static %}

I'm trying to make django compress work but I believe it does not work because of my {% static %} use. My template is (I'm using pyjade but doesn't matter): - load staticfiles - load compress | {% compress css %} link(rel="stylesheet", href="{%…
Diolor
  • 13,181
  • 30
  • 111
  • 179
1
2 3 4 5 6 7 8