Changeset cafab4c


Ignore:
Timestamp:
Jan 8, 2010, 4:49:02 AM (16 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, client
Children:
b0f541c
Parents:
70ce03a
git-author:
Alex Dehnert <adehnert@…> (01/08/10 04:49:02)
git-committer:
Alex Dehnert <adehnert@…> (01/08/10 04:49:02)
Message:

Serve static media

Location:
treasury
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • treasury/settings.py

    rf468e6d rcafab4c  
    22import os
    33
    4 APP_ROOT = os.path.dirname(__file__)
     4SITE_ROOT = os.path.normpath(os.path.dirname(__file__))
    55DEFAULT_DOMAIN = 'mit.edu'
    66
     
    4040# Absolute path to the directory that holds media.
    4141# Example: "/home/media/media.lawrence.com/"
    42 MEDIA_ROOT = ''
     42MEDIA_ROOT = SITE_ROOT + '/media/'
     43print "MEDIA_ROOT='%s'" % (MEDIA_ROOT, )
    4344
    4445# URL that handles the media served from MEDIA_ROOT. Make sure to use a
    4546# trailing slash if there is a path component (optional in other cases).
    4647# Examples: "http://media.lawrence.com", "http://example.com/media/"
    47 MEDIA_URL = ''
     48MEDIA_URL = '/media/'
    4849
    4950# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
    5051# trailing slash.
    5152# Examples: "http://foo.com/media/", "/media/".
    52 ADMIN_MEDIA_PREFIX = '/media/'
     53ADMIN_MEDIA_PREFIX = '/media/admin/'
    5354
    5455# Make this unique, and don't share it with anybody.
     
    7677    # Always use forward slashes, even on Windows.
    7778    # Don't forget to use absolute paths, not relative paths.
    78     APP_ROOT + '/templates/',
     79    SITE_ROOT + '/templates/',
    7980)
    8081
  • treasury/urls.py

    rdbc9bf9 rcafab4c  
    11from django.conf.urls.defaults import *
    22from django.contrib.auth.views import login
     3
     4import settings
    35
    46# Necessary views
     
    2325    (r'^accounts/login/', login, ),
    2426)
     27
     28if settings.DEBUG:
     29    from django.views.static import serve
     30    _media_url = settings.MEDIA_URL
     31    if _media_url.startswith('/'):
     32        _media_url = _media_url[1:]
     33        urlpatterns += patterns('',
     34                                (r'^%s(?P<path>.*)$' % _media_url,
     35                                serve,
     36                                {'document_root': settings.MEDIA_ROOT}))
     37    del(_media_url, serve)
Note: See TracChangeset for help on using the changeset viewer.