0

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()))
Zacharoo
  • 113
  • 1
  • 10
  • Could you upload some of your code? Debugging broken code is 'sometimes' easier than writing a new solution. – Joe Jan 02 '14 at 00:31
  • I wouldnt even know what code is relevant as I have had people tell me to edit apache config, settings.py, urls.py, templates, my directories, etc. – Zacharoo Jan 02 '14 at 10:27
  • @user2366105: did you follow the steps at https://docs.djangoproject.com/en/1.5/howto/static-files/ ? You should be able to configure Django and Apache/WSGI without additional apps (unless, of course, your wish to host your static files in a way that Django doesn't support out of the box). – Simeon Visser Jan 02 '14 at 14:32
  • I want to host my static files in the same place as the rest of my website, I think. I did follow those instructions on the django project site and was unsuccessful which is why I went to dj-static. – Zacharoo Jan 02 '14 at 17:29

1 Answers1

1

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.

Simeon Visser
  • 118,920
  • 18
  • 185
  • 180