Revision bfbdb021 snf-webproject/synnefo/webproject/urls.py

b/snf-webproject/synnefo/webproject/urls.py
43 43
)
44 44

  
45 45
if getattr(settings, 'WEBPROJECT_SERVE_STATIC', settings.DEBUG):
46
    for module, ns in settings.STATIC_FILES.iteritems():
47
        module = import_module(module)
48
        static_root = os.path.join(os.path.dirname(module.__file__), 'static')
46

  
47
    for module_name, ns in settings.STATIC_FILES.iteritems():
48
        module = import_module(module_name)
49
        app_dir = 'static'
50

  
51
        # hook defined that application contains media files in other than
52
        # ``static`` directory
53
        # (e.g. django.contrib.admin which contains media files in media dir)
54
        if type(ns) == tuple:
55
            app_dir = ns[0]
56
            ns = ns[1]
57

  
58
        static_root = os.path.join(os.path.dirname(module.__file__), app_dir)
49 59
        if ns:
50 60
            # app contains static files in <appname>/static/
51 61
            urlns = ns
52
            urlpatterns += patterns('', url(r'^%s%s/(?P<path>.*)$' % \
53
                 (settings.MEDIA_URL.lstrip("/"), urlns),
62
            url_r = r'^%s%s/(?P<path>.*)$' % (settings.MEDIA_URL.lstrip("/"),
63
                                              urlns)
64
            urlpatterns += patterns('', url(url_r,
54 65
                 'django.views.static.serve',
55 66
                 {'document_root': static_root,
56 67
                  'show_indexes': getattr(settings,

Also available in: Unified diff