Hi Everyone,
This may seem like a very stupid question, but what exactly is the
difference between MEDIA and STATIC? I read through the Django doc and it
seems like STATIC is for css,js,img... etc., while MEDIA is for user
uploaded files?
But I'm confused because things do not work exactly like the documentation
says, so I hope someone who's defined and used MEDIA and STATIC (esp. in a
production env.) to enlighten me a little bit.
- serving STATIC -
# settings.py
STATIC_ROOT = '/Users/eiji/Sites/assets/static/'
STATIC_URL = '/static/'
TEMPLATE_CONTEXT_PROCESSORS = (
...
"django.core.context_processors.static",
...
)
Then in one of my templates, I have the following:
<link rel="stylesheet" href="{{ STATIC_URL }}css/reset.css">
Even though there is a 'css' subdirectory and a 'reset.css' file, this
doesn't work. It's only when I add the following into the settings.py file
that it works:
STATICFILES_DIRS = (
('css', '/Users/eiji/Sites/assets/static/css'),
('img', '/Users/eiji/Sites/assets/static/img'),
('js', '/Users/eiji/Sites/assets/static/js'),
)
But at least this now works.
I would now like to play around with the MEDIA definitions so I can make
references like:
MEDIA_URL/members/eiji/videos/xyz.mov
MEDIA_URL/members/eiji/music/abc.mp3
and so on...
I tried setting:
MEDIA_ROOT = '/Users/eiji/Sites/assets/media/'
MEDIA_URL = '/media/'
and of course, it doesn't work. The templates files translate both
MEDIA_ROOT and MEDIA_URL variables as null.
So, my questions are:
1. Why don't the STATIC variables work without me having to have to
define STATICFILES_DIRS?
2. Why can't I get the MEDIA variables to work. What else must I define to
get this to work?
Thank you!
Eiji
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.