[Fixed]-Django 1.10 – why the app does not work with DEBUG=FALSE

1πŸ‘

The development server knows how to serve static files but you have to set some settings for this to work in production. You can read about it here.

That will also point you to this page.

You need to do the following:

  1. Make sure that django.contrib.staticfiles is included in your INSTALLED_APPS.
  2. In your settings file, define STATIC_URL.
  3. Use the static template tag to build the URL for the given relative path. For example:

{% load static %}
<img src="{% static "my_app/example.jpg" %}" alt="My image"/>

  1. Store your static files in a folder called static in your app. For example my_app/static/my_app/example.jpg.
  2. Set the STATICFILES_DIRS setting in your settings file. For example:

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
'/var/www/static/',
]

πŸ‘€Eric Bulloch

Leave a comment