Commits

Donald Stufft committed 50a618a

Added support for django-staticfiles STATIC_URL settings. Falls back to MEDIA_URL

  • Participants
  • Parent commits 4c10a7b

Comments (0)

Files changed (3)

File admin_tools/dashboard/templatetags/admin_tools_dashboard_tags.py

     if dashboard is None:
         dashboard = get_dashboard(context, location)
 
+    try:
+        media_url = settings.STATIC_URL
+    except AttributeError:
+        media_url = settings.MEDIA_URL
+
     dashboard.init_with_context(context)
     context.update({
         'template': dashboard.template,
         'dashboard': dashboard,
         'split_at': math.ceil(float(len(dashboard.children))/float(dashboard.columns)),
-        'media_url': settings.MEDIA_URL.rstrip('/'),
+        'media_url': media_url.rstrip('/'),
         'has_disabled_modules': len([m for m in dashboard.children \
                                 if not m.enabled]) > 0,
     })
     if dashboard is None:
         dashboard = get_dashboard(context, location)
 
+    try:
+        media_url = settings.STATIC_URL
+    except AttributeError:
+        media_url = settings.MEDIA_URL
+
     context.update({
         'template' : 'dashboard/css.html',
         'css_files': dashboard.Media.css,
-        'media_url': settings.MEDIA_URL.rstrip('/'),
+        'media_url': media_url.rstrip('/'),
     })
     return context
 admin_tools_render_dashboard_css = tag_func(admin_tools_render_dashboard_css)

File admin_tools/menu/templatetags/admin_tools_menu_tags.py

     if menu is None:
         menu = get_admin_menu()
 
+    try:
+        media_url = settings.STATIC_URL
+    except AttributeError:
+        media_url = settings.MEDIA_URL
+
     menu.init_with_context(context)
     has_bookmark_item = False
     bookmark = None
     context.update({
         'template': menu.template,
         'menu': menu,
-        'media_url': settings.MEDIA_URL.rstrip('/'),
+        'media_url': media_url.rstrip('/'),
         'has_bookmark_item': has_bookmark_item,
         'bookmark': bookmark,
     })
     if menu is None:
         menu = get_admin_menu()
 
+    try:
+        media_url = settings.STATIC_URL
+    except AttributeError:
+        media_url = settings.MEDIA_URL
+
     context.update({
         'template': 'menu/css.html',
         'css_files': menu.Media.css,
-        'media_url': settings.MEDIA_URL.rstrip('/'),
+        'media_url': media_url.rstrip('/'),
     })
     return context
 admin_tools_render_menu_css = tag_func(admin_tools_render_menu_css)

File admin_tools/theming/templatetags/theming_tags.py

     Template tag that renders the needed css files for the theming app.
     """
     css = getattr(settings, 'ADMIN_TOOLS_THEMING_CSS', False)
+    try:
+        media_url = settings.STATIC_URL
+    except AttributeError:
+        media_url = settings.MEDIA_URL
     if css:
-        css = os.path.join(settings.MEDIA_URL, css)
+        css = os.path.join(media_url, css)
     else:
         css = os.path.join(
-            getattr(settings, 'ADMIN_TOOLS_MEDIA_URL', settings.MEDIA_URL),
+            getattr(settings, 'ADMIN_TOOLS_MEDIA_URL', media_url),
             'admin_tools',
             'css',
             'theming.css'