Reputation: 21
I am completely beginner of Django / Python.
I wrote my app in Django 1.10, everything works good and now I would like to move the app at production server.
So, I have set the DEBUG on FALSE and suddenly whole app stopped working. It means, generally an app works, but static links doesn't work, the program does not see js, css files.
Do you know - why?
Thanks
Upvotes: 0
Views: 532
Reputation: 897
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:
django.contrib.staticfiles
is included in your INSTALLED_APPS
.STATIC_URL
.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"/>
my_app/static/my_app/example.jpg
.STATICFILES_DIRS
setting in your settings file. For example:STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
'/var/www/static/',
]
Upvotes: 1