Opened 6 years ago

Closed 5 years ago

Last modified 4 years ago

#11478 closed (fixed)

jsi18n loading from templates within django/contrib/admin/templates/ shouldn't use "../"s

Reported by: greatlemer <greatlemer+django@…> Owned by: jezdez
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When creating a custom change_form.html for use on a different url to the usual create item locations I discovered that the jsi18n scripts were failing to load (side effecting various elements on the page such as many to many selectors collapsable fieldsets). I tracked this down to the fact that the javascript was being loaded relative to the location of the page. After further investigation I noticed that the following templates also used the same style of importing for javascript (all within the django/contrib/admin/templates directory).
admin/auth/user/change_password.html
admin/change_form.html
admin/change_list.html

Is it possible that these imports could be altered to use some sort of url reversal?

The svn version I have checked this against was 11231 although it seems to be there in 1.0.2 also.

Attachments (1)

11478-jsi18n-reverse-urls-needs-10061.diff (2.2 KB) - added by ramiro 6 years ago.
Patch for this issue, it depends on recent patch for #10061 from Russell being applied first

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by ramiro

Patch for this issue, it depends on recent patch for #10061 from Russell being applied first

comment:1 Changed 6 years ago by ramiro

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by ramiro

With #10061 fixed on r11250, now the patch should work when applied to trunk after hat revision. Please report back your experiences with it if you manage to give it a try.

comment:3 Changed 6 years ago by greatlemer <greatlemer+django@…>

That patch seems to do the job. The javascript is now loading fine for me wherever I access it from.

Thanks!

comment:4 Changed 6 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 5 years ago by jezdez

  • Owner changed from nobody to jezdez
  • Status changed from new to assigned

comment:6 Changed 5 years ago by jezdez

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [12138]) Fixed #11478 - Use namespacing for URLs to i18n JavaScript in admin.

comment:7 Changed 5 years ago by jezdez

(In [12238]) [1.1.X] Fixed #11478 - Use namespacing for URLs to i18n JavaScript in admin.

comment:8 Changed 4 years ago by philomat

Could/should the i18n_javascript() method of AdminSite be improved to include JS catalogs from all or selected INSTALLED_APPS? The way it is now, you can easily create the appropriate JS message files as desribed in the Django manual, but only the package "django.conf" is loaded by said method.

Actually loading your custom catalog for the admin is a bit tedious now. You basically have to duplicate said method and add a custom URL to your ModelAdmin and put a script tag in the corresponding admin template.

Note: See TracTickets for help on using tickets.
Back to Top