Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#14895 closed (fixed)

USE_THOUSAND_SEPARATOR causes error on group admin operations

Reported by: Tuttle Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: l10n localization thousands
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Line in django/contrib/admin/templates/admin/delete_selected_confirmation.html:

    <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk }}" />

obj.pk is rendered with thousands separated (if such localization is enabled), results in exception like

    ValueError: invalid literal for int() with base 10: '1 307'

on submit.

Attachments (3)

Change History (9)

comment:1 Changed 3 years ago by julien

  • Has patch set
  • milestone set to 1.3
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

I can confirm this bug. Formatting the pk as a string resolves the issue (see patch attached).

comment:2 Changed 3 years ago by julien

  • Triage Stage changed from Accepted to Ready for checkin

In this patch, the stringformat template filter forces the id to be rendered without USE_THOUSAND_SEPARATOR getting in the way. I'm not sure whether it is the most elegant solution though, so you might have a better fix to suggest.

Cheekily RFC'ing so it gets a core dev's attention for 1.3 ;)

comment:3 Changed 3 years ago by russellm

  • Triage Stage changed from Ready for checkin to Accepted

This sort of problem is the exact reason that we introduced the unlocalize filter. I suspect that this patch is actually pretty close to being RFC, mod that little detail.

comment:4 Changed 3 years ago by julien

  • Triage Stage changed from Accepted to Ready for checkin

Thanks for the suggestion, Russell. This feels much cleaner! :)

comment:5 Changed 3 years ago by russellm

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

In [15435]:

Fixed #14895 -- Ensure that USE_THOUSAND_SEPARATOR doesn't break the delete confirmation page. Thanks to Tuttle for the report, and Julien Phalip for the patch.

comment:6 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.