Zacharoo
Zacharoo

Reputation: 113

Static and Media files in django 1.5

I am making a site, I am the only one that will be uploading anything to the site. It seems like its more complicated to have two separate directories media and static would it be unreasonable to just funnel everything into static?

I have not yet been able to figure out how to make Django serve my static files. I'm trying to have everything on the same server but have not had any success. I have tried everything (at least I think I have) from http://djangoproject.com and I tried using this https://github.com/kennethreitz/dj-static earlier today but nothing seems to be working for me.

My settings.py file:

MEDIA_ROOT = 'media'
MEDIA_URL = '/media/'
STATIC_ROOT = '/staticfiles/'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

My wsgi.py file

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

from django.core.wsgi import get_wsgi_application
from dj_static import Cling, MediaCling

application = Cling(MediaCling(get_wsgi_application()))

Upvotes: 0

Views: 226

Answers (1)

Simeon Visser
Simeon Visser

Reputation: 122326

Conceptually it's better to separate static content (in /static/) from user-uploaded content (in /media/). Even if you're the only one uploading to the site. For example, if you want to make a backup of your own uploads you know that backing up /media/ is sufficient. Your static content in /static/ should hopefully be part of a version control system so you don't need to back that up separately.

Upvotes: 1

Related Questions