diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py index d15716b..04a3492 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 35c3cde..81e8ae5 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 c280f50..b18b0aa 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 9282440..4b3c429 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 %} {% block title %}{% endblock %} diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html index c5e428d..56661e9 100644 --- a/django/contrib/admin/templates/admin/change_form.html +++ b/django/contrib/admin/templates/admin/change_form.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 }} diff --git a/django/contrib/admin/templates/admin/change_list.html b/django/contrib/admin/templates/admin/change_list.html index 29af47f..24c6d8c 100644 --- a/django/contrib/admin/templates/admin/change_list.html +++ b/django/contrib/admin/templates/admin/change_list.html @@ -1,5 +1,5 @@ {% extends "admin/base_site.html" %} -{% load i18n static admin_list %} +{% load i18n admin_static admin_list %} {% load url from future %} {% block extrastyle %} {{ block.super }} diff --git a/django/contrib/admin/templates/admin/change_list_results.html b/django/contrib/admin/templates/admin/change_list_results.html index 233d4e1..b1db647 100644 --- a/django/contrib/admin/templates/admin/change_list_results.html +++ b/django/contrib/admin/templates/admin/change_list_results.html @@ -1,4 +1,4 @@ -{% load i18n static %} +{% load i18n admin_static %} {% if result_hidden_fields %}
{# DIV for HTML validation #} {% for item in result_hidden_fields %}{{ item }}{% endfor %} diff --git a/django/contrib/admin/templates/admin/edit_inline/stacked.html b/django/contrib/admin/templates/admin/edit_inline/stacked.html index 7e69450..476e261 100644 --- a/django/contrib/admin/templates/admin/edit_inline/stacked.html +++ b/django/contrib/admin/templates/admin/edit_inline/stacked.html @@ -1,4 +1,4 @@ -{% load i18n static %} +{% load i18n admin_static %}

{{ inline_admin_formset.opts.verbose_name_plural|title }}

{{ inline_admin_formset.formset.management_form }} diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html index 8294227..29db95a 100644 --- a/django/contrib/admin/templates/admin/edit_inline/tabular.html +++ b/django/contrib/admin/templates/admin/edit_inline/tabular.html @@ -1,4 +1,4 @@ -{% load i18n static admin_modify %} +{% load i18n admin_static admin_modify %}