On Apr 2, 11:30 am, Dexter <[email protected]> wrote:
> Hi,
> > Can someone please
> > explicitly specify what needs to go in MEDIA_URL and MEDIA_ROOT and
> > how does urls.py routes to a cross domain media server. I am not
> > interested in any local directory structure to accomplish this task
> > because that is insecure and inefficient. Any help would be
> > appreciated.
It doesn't do what you're thinking it does. ``settings.MEDIA_ROOT``
tells Django where the media is going to be stored if you use Django's
storage API for uploads, etc. ``settings.MEDIA_URL`` is what you use
to generate URLs for media (eg, ``<img src="{{ MEDIA_URL }}/logo.jpg"
alt="Logo" />``). Django doesn't take the two settings and some how
magically route incoming traffic on ``settings.MEDIA_URL`` and route
it to ``settings.MEDIA_ROOT``, and certainly not when your media is on
a separate server, and you're right, that would be insecure to do. If
you want to server static media from the same server during dev, you
could do something like this:
if settings.DEBUG:
urlpatterns += patterns('',
# Static Media (development only)
url(r'^static/(?P<path>.*)$',
'django.views.static.serve',
{
'document_root': 'C:/path/to/my_media'
}
)
)
Then your media could be served via http://localhost:8080/static/logo.jpg
Remember to only do this during dev as it's not secure or scalable.
--
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.