WebFaction
Community site: login faq

In my Django 1.10 app static files work fine with DEBUG = True but aren't served with DEBUG = False

Why?

In settings.py I have:

STATIC_URL = '/static/'
STATIC_ROOT = '/home/username/webapps/static_media_app/'

urls.py contains

from django.conf import settings
from django.conf.urls.static import static
if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

html includes the following

{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'css/driven.css' %}" />

asked 28 Oct '16, 14:55

nickw
524
accept rate: 0%


It appears you don't have the static files app being served by your website entry. Please have a look at the documentation here.

permanent link

answered 28 Oct '16, 15:14

bmeyer71 ♦♦
1.5k3613
accept rate: 33%

I've read through that documentation more than once, although that's not to say I understood it all correctly.

I have got the django.contrib.staticfiles app listed in myproject’s INSTALLED_APPS setting - is that what you meant?

(28 Oct '16, 17:44) nickw

No. You need to create the static app to collect the files to then mount that application as described. eg: /static

(28 Oct '16, 17:51) bmeyer71 ♦♦

I've done: python3.5 manage.py collectstatic, to collect the static files over at my static media app and restarted the django app, but still no static files are served.

When you say mount the app as described that's what I've done with the STATIC_URL and STATIC_ROOT settings I think.

(28 Oct '16, 19:09) nickw

The mounting of the app needs to be done in the control panel under the website entry. That is different than your settings.py

(28 Oct '16, 19:15) bmeyer71 ♦♦

Wow, I really thought I'd done that, but it seems I hadn't...

Thank you so much!

(28 Oct '16, 19:49) nickw
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×125
×3

question asked: 28 Oct '16, 14:55

question was seen: 6,051 times

last updated: 28 Oct '16, 19:49

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM