Changeset 8913d43


Ignore:
Timestamp:
May 12, 2010, 11:05:42 PM (15 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, fysm-4-1, iframe, space-access, stable, stage, test-hooks
Children:
80982de
Parents:
ca9348d
git-author:
Alex Dehnert <adehnert@…> (05/12/10 23:05:42)
git-committer:
Alex Dehnert <adehnert@…> (05/12/10 23:05:42)
Message:

Serve up media

Location:
asadb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • asadb/settings.py

    r158cc8d r8913d43  
    11# Django settings for asadb project.
     2import os
     3import sys
     4
     5SITE_ROOT = os.path.normpath(os.path.dirname(__file__))
     6SITE_WEB_PATH = ''
     7
    28
    39DEBUG = True
     
    3844# Absolute path to the directory that holds media.
    3945# Example: "/home/media/media.lawrence.com/"
    40 MEDIA_ROOT = ''
     46MEDIA_ROOT = SITE_ROOT + '/media/'
    4147
    4248# URL that handles the media served from MEDIA_ROOT. Make sure to use a
    4349# trailing slash if there is a path component (optional in other cases).
    4450# Examples: "http://media.lawrence.com", "http://example.com/media/"
    45 MEDIA_URL = ''
     51MEDIA_URL = SITE_WEB_PATH + '/media/'
    4652
    4753# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
    4854# trailing slash.
    4955# Examples: "http://foo.com/media/", "/media/".
    50 ADMIN_MEDIA_PREFIX = '/media/'
     56ADMIN_MEDIA_PREFIX = SITE_WEB_PATH + '/media/admin/'
    5157
    5258# Make this unique, and don't share it with anybody.
  • asadb/urls.py

    r0c5539a r8913d43  
    44from django.contrib import admin
    55admin.autodiscover()
     6
     7import settings
    68
    79urlpatterns = patterns('',
     
    1618    (r'^admin/', include(admin.site.urls)),
    1719)
     20
     21if settings.DEBUG:
     22    from django.views.static import serve
     23    _media_url = settings.MEDIA_URL
     24    if _media_url.startswith('/'):
     25        _media_url = _media_url[1:]
     26        urlpatterns += patterns('',
     27                                (r'^%s(?P<path>.*)$' % _media_url,
     28                                serve,
     29                                {'document_root': settings.MEDIA_ROOT}))
     30    del(_media_url, serve)
Note: See TracChangeset for help on using the changeset viewer.