This is very important question, because it take a lot of time when you met Django for first time. This guide is for setting up Django
STATIC files for development environment and it will be more compact then official guide, though I'll give a reference to it.
Configuration of settings.py and urls.py
First you should consult official documentation and be sure that you’ve setup proper middleware classes. If you create new project with
manage.pyor using PyCharm then this classes is already in there, but you should check it anyway.
Then you should specify
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'upgrademystartup', 'static')MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'upgrademystartup', 'media')STATICFILES_DIRS = (
You could add aditional static files directory if you put it in the tuple
That’s all. Now you’ll see that all your static files applied you your project without other actions thanks to
'django.contrib.staticfiles'. You shouldn't add anything else to
urls.py, because middleware manage this for you. But wait. What is about
MEDIA? It won't work this way. You should add this in your urls after everything else:
urlpatterns += static(MEDIA_URL, document_root=MEDIA_ROOT)
That’s all. It helps me and I hope this guide will help someone, because it’s shorter then oficcial guidelines, made for Django 1.8 and really simple.