Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#14895 closed (fixed)

USE_THOUSAND_SEPARATOR causes error on group admin operations

Reported by: Vlada Macek 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)

14895_delete_confirmation_1000_separator.diff (776 bytes) - added by Julien Phalip 6 years ago.
14895_delete_confirmation_1000_separator_plus_tests.diff (2.5 KB) - added by Julien Phalip 6 years ago.
14895_delete_confirmation_1000_separator_unlocalize.diff (2.7 KB) - added by Julien Phalip 6 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 6 years ago by Julien Phalip

Has patch: set
milestone: 1.3
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

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

Changed 6 years ago by Julien Phalip

comment:2 Changed 6 years ago by Julien Phalip

Triage Stage: AcceptedReady 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 6 years ago by Russell Keith-Magee

Triage Stage: Ready for checkinAccepted

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 6 years ago by Julien Phalip

Triage Stage: AcceptedReady for checkin

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

comment:5 Changed 6 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

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 5 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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