diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py index d15716b909..04a3492e1c 100644 --- a/django/contrib/admin/helpers.py +++ b/django/contrib/admin/helpers.py @@ -1,6 +1,7 @@ from django import forms from django.contrib.admin.util import (flatten_fieldsets, lookup_field, display_for_field, label_for_field, help_text_for_field) +from django.contrib.admin.templatetags.admin_static import static from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ObjectDoesNotExist from django.db.models.fields.related import ManyToManyRel @@ -75,7 +76,7 @@ class Fieldset(object): def _media(self): if 'collapse' in self.classes: js = ['jquery.min.js', 'jquery.init.js', 'collapse.min.js'] - return forms.Media(js=['admin/js/%s' % url for url in js]) + return forms.Media(js=[static('admin/js/%s' % url) for url in js]) return forms.Media() media = property(_media) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 35c3cde0fc..81e8ae5614 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -6,6 +6,7 @@ from django.forms.models import (modelform_factory, modelformset_factory, from django.contrib.contenttypes.models import ContentType from django.contrib.admin import widgets, helpers from django.contrib.admin.util import unquote, flatten_fieldsets, get_deleted_objects, model_format_dict +from django.contrib.admin.templatetags.admin_static import static from django.contrib import messages from django.views.decorators.csrf import csrf_protect from django.core.exceptions import PermissionDenied, ValidationError @@ -350,7 +351,8 @@ class ModelAdmin(BaseModelAdmin): return self.get_urls() urls = property(urls) - def _media(self): + @property + def media(self): js = [ 'core.js', 'admin/RelatedObjectLookups.js', @@ -363,8 +365,7 @@ class ModelAdmin(BaseModelAdmin): js.extend(['urlify.js', 'prepopulate.min.js']) if self.opts.get_ordered_objects(): js.extend(['getElementsBySelector.js', 'dom-drag.js' , 'admin/ordering.js']) - return forms.Media(js=['admin/js/%s' % url for url in js]) - media = property(_media) + return forms.Media(js=[static('admin/js/%s' % url) for url in js]) def has_add_permission(self, request): """ @@ -1322,14 +1323,14 @@ class InlineModelAdmin(BaseModelAdmin): if self.verbose_name_plural is None: self.verbose_name_plural = self.model._meta.verbose_name_plural - def _media(self): + @property + def media(self): js = ['jquery.min.js', 'jquery.init.js', 'inlines.min.js'] if self.prepopulated_fields: js.extend(['urlify.js', 'prepopulate.min.js']) if self.filter_vertical or self.filter_horizontal: js.extend(['SelectBox.js', 'SelectFilter2.js']) - return forms.Media(js=['admin/js/%s' % url for url in js]) - media = property(_media) + return forms.Media(js=[static('admin/js/%s' % url) for url in js]) def get_formset(self, request, obj=None, **kwargs): """Returns a BaseInlineFormSet class for use in admin add/change views.""" diff --git a/django/contrib/admin/templates/admin/auth/user/change_password.html b/django/contrib/admin/templates/admin/auth/user/change_password.html index c280f50d60..b18b0aabf3 100644 --- a/django/contrib/admin/templates/admin/auth/user/change_password.html +++ b/django/contrib/admin/templates/admin/auth/user/change_password.html @@ -1,5 +1,5 @@ {% extends "admin/base_site.html" %} -{% load i18n static admin_modify %} +{% load i18n admin_static admin_modify %} {% load url from future %} {% block extrahead %}{{ block.super }} {% url 'admin:jsi18n' as jsi18nurl %} diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html index 928244053f..4b3c42934f 100644 --- a/django/contrib/admin/templates/admin/base.html +++ b/django/contrib/admin/templates/admin/base.html @@ -1,4 +1,4 @@ -{% load static %}{% load url from future %} +{% load admin_static %}{% load url from future %}