diff --git a/django/django/contrib/admin/options.py b/django/django/contrib/admin/options.py
index ad5c2f1..7f9183e 100644
a
|
b
|
from django.contrib.admin.util import unquote, flatten_fieldsets, get_deleted_ob
|
8 | 8 | from django.core.exceptions import PermissionDenied |
9 | 9 | from django.db import models, transaction |
10 | 10 | from django.db.models.fields import BLANK_CHOICE_DASH |
| 11 | from django.conf import settings |
11 | 12 | from django.http import Http404, HttpResponse, HttpResponseRedirect |
12 | 13 | from django.shortcuts import get_object_or_404, render_to_response |
13 | 14 | from django.utils.datastructures import SortedDict |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
220 | 221 | def get_urls(self): |
221 | 222 | from django.conf.urls.defaults import patterns, url |
222 | 223 | |
223 | | def wrap(view): |
| 224 | def wrap(view, cacheable=False): |
224 | 225 | def wrapper(*args, **kwargs): |
225 | | return self.admin_site.admin_view(view)(*args, **kwargs) |
| 226 | return self.admin_site.admin_view(view, cacheable)(*args, **kwargs) |
226 | 227 | return update_wrapper(wrapper, view) |
227 | 228 | |
228 | 229 | info = self.model._meta.app_label, self.model._meta.module_name |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
240 | 241 | url(r'^(.+)/delete/$', |
241 | 242 | wrap(self.delete_view), |
242 | 243 | name='%s_%s_delete' % info), |
| 244 | url(r'^jsi18n/$', |
| 245 | wrap(self.i18n_javascript, cacheable=True), |
| 246 | name='%s_%s_jsi18n' % info), |
243 | 247 | url(r'^(.+)/$', |
244 | 248 | wrap(self.change_view), |
245 | 249 | name='%s_%s_change' % info), |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
251 | 255 | urls = property(urls) |
252 | 256 | |
253 | 257 | def _media(self): |
254 | | from django.conf import settings |
255 | | |
256 | 258 | js = ['js/core.js', 'js/admin/RelatedObjectLookups.js'] |
257 | 259 | if self.actions is not None: |
258 | 260 | js.extend(['js/getElementsBySelector.js', 'js/actions.js']) |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
1091 | 1093 | "admin/object_history.html" |
1092 | 1094 | ], context, context_instance=context_instance) |
1093 | 1095 | |
| 1096 | def i18n_javascript(self, request): |
| 1097 | """ |
| 1098 | Displays the i18n JavaScript that the Django admin requires. |
| 1099 | |
| 1100 | This takes into account the USE_I18N setting. If it's set to False, the |
| 1101 | generated JavaScript will be leaner and faster. |
| 1102 | """ |
| 1103 | if settings.USE_I18N: |
| 1104 | from django.views.i18n import javascript_catalog |
| 1105 | else: |
| 1106 | from django.views.i18n import null_javascript_catalog as javascript_catalog |
| 1107 | |
| 1108 | for package in settings.INSTALLED_APPS: |
| 1109 | if self.opts.app_label == package.split('.')[-1]: |
| 1110 | break |
| 1111 | |
| 1112 | return javascript_catalog(request, packages=('django.conf', package)) |
| 1113 | |
1094 | 1114 | # |
1095 | 1115 | # DEPRECATED methods. |
1096 | 1116 | # |
… |
… |
class InlineModelAdmin(BaseModelAdmin):
|
1147 | 1167 | self.verbose_name_plural = self.model._meta.verbose_name_plural |
1148 | 1168 | |
1149 | 1169 | def _media(self): |
1150 | | from django.conf import settings |
1151 | 1170 | js = [] |
1152 | 1171 | if self.prepopulated_fields: |
1153 | 1172 | js.append('js/urlify.js') |
diff --git a/django/django/contrib/admin/sites.py b/django/django/contrib/admin/sites.py
index 031cf36..3e612ae 100644
a
|
b
|
class AdminSite(object):
|
207 | 207 | url(r'^password_change/done/$', |
208 | 208 | wrap(self.password_change_done, cacheable=True), |
209 | 209 | name='password_change_done'), |
210 | | url(r'^jsi18n/$', |
211 | | wrap(self.i18n_javascript, cacheable=True), |
212 | | name='jsi18n'), |
213 | 210 | url(r'^r/(?P<content_type>\d+)/(?P<object_id>.+)/$', |
214 | 211 | 'django.views.defaults.shortcut'), |
215 | 212 | url(r'^(?P<app_label>\w+)/$', |
… |
… |
class AdminSite(object):
|
270 | 267 | from django.contrib.auth.views import password_change_done |
271 | 268 | return password_change_done(request) |
272 | 269 | |
273 | | def i18n_javascript(self, request): |
274 | | """ |
275 | | Displays the i18n JavaScript that the Django admin requires. |
276 | | |
277 | | This takes into account the USE_I18N setting. If it's set to False, the |
278 | | generated JavaScript will be leaner and faster. |
279 | | """ |
280 | | if settings.USE_I18N: |
281 | | from django.views.i18n import javascript_catalog |
282 | | else: |
283 | | from django.views.i18n import null_javascript_catalog as javascript_catalog |
284 | | return javascript_catalog(request, packages='django.conf') |
285 | | |
286 | 270 | def logout(self, request): |
287 | 271 | """ |
288 | 272 | Logs out the user for the given HttpRequest. |
diff --git a/django/django/contrib/admin/templates/admin/auth/user/change_password.html b/django/django/contrib/admin/templates/admin/auth/user/change_password.html
index d28dd0f..3ee4e1b 100644
a
|
b
|
|
1 | 1 | {% extends "admin/base_site.html" %} |
2 | 2 | {% load i18n admin_modify adminmedia %} |
3 | 3 | {% block extrahead %}{{ block.super }} |
4 | | <script type="text/javascript" src="../../../../jsi18n/"></script> |
| 4 | <script type="text/javascript" src="../../jsi18n/"></script> |
5 | 5 | {% endblock %} |
6 | 6 | {% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/forms.css" />{% endblock %} |
7 | 7 | {% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %} |
diff --git a/django/django/contrib/admin/templates/admin/change_form.html b/django/django/contrib/admin/templates/admin/change_form.html
index a650261..e4a0529 100644
a
|
b
|
|
2 | 2 | {% load i18n admin_modify adminmedia %} |
3 | 3 | |
4 | 4 | {% block extrahead %}{{ block.super }} |
5 | | <script type="text/javascript" src="../../../jsi18n/"></script> |
| 5 | <script type="text/javascript" src="../jsi18n/"></script> |
6 | 6 | {{ media }} |
7 | 7 | {% endblock %} |
8 | 8 | |
diff --git a/django/django/contrib/admin/templates/admin/change_list.html b/django/django/contrib/admin/templates/admin/change_list.html
index 7d110e4..9840382 100644
a
|
b
|
|
6 | 6 | <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/changelists.css" /> |
7 | 7 | {% if cl.formset %} |
8 | 8 | <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/forms.css" /> |
9 | | <script type="text/javascript" src="../../jsi18n/"></script> |
| 9 | <script type="text/javascript" src="./jsi18n/"></script> |
10 | 10 | {% endif %} |
11 | 11 | {{ media }} |
12 | 12 | {% if not actions_on_top and not actions_on_bottom %} |