Sphene Community Tools


Copyright © 2007-2018 by Herbert Poul

You are not logged in.

Change Language:

AddThis Social Bookmark Button

A Django site.

Powered by Sphene Community Tools
Board » General » Where are media files kept? What are the urls?

Posting this, I have several ideas where the media files are, ala banner images, that I can use. I'll check there, but I thought it might be useful to post this in the general forum.

If I remember right, there is a setting in urls.py for media files.
I am using {{ MEDIA URL }}/sphene/community/....... I haven't found where the MEDIA_URL is set, but it'll work for now.
But what are you asking for?

MEDIA_URL is set in settings.py - as in all Django applications, but this is only URL. Filesystem location of media files is shown by MEDIA_ROOT setting.

There might also be some urls definitions for media in urls.py (usually used only in DEBUG mode), but in production you should serve static files from another server.
I am using {{ MEDIA URL }}/sphene/community/....... I haven't found where the MEDIA_URL is set, but it'll work for now.
As Pigletto said it is set in settings.py, but it is possible to use {{ MEDIA_URL }} in your templates because of 'django.core.context_processors.media' context processor which is enabled by default. No magic here.

You use: {{ MEDIA URL }}/sphene/community/..... See: http://docs.djangoproject.com/en/1.2/ref/settings/#media-url and please note that valid MEDIA_URL has a trailing slash. Because of that you should use {{ MEDIA_URL }}sphene/community/... (no slash after MEDIA_URL variable).
Hi, just checking back to this help forum again. I read the posts in the past, but I didn't write back. Thank you very much for explaining {{ MEDIA_URL }}. I see that django itself does not take care of static (media) files on servers with Apache etc.... I'm not to that point yet so I'm fine with the development context. I'm now on to the external stylesheet after having to put <style> tags in base.html. I'm trying to move beyond that. So I'm dealing with MEDIA_ROOT again. I'm jumping from directory to directory and I can't get the stylesheet to work. I put the href="style.css" in the base.html and now I put style.css in MEDIA_ROOT= os.path.join(ROOT_PATH, 'media/'). It no worky. Needless to say, I've been jumping from directory to directory putting in style.css in all of them til it works. I'm not giving up and I know it's a simple solution. I am checking the basic djangoproject.com documentation too.

Please login to post a reply.

Powered by Sphene Community Tools