Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#22245 closed Bug (fixed)

Widget on DecimalField subclass ignored

Reported by: jeroen.pulles@… Owned by: nobody
Component: Forms Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a subclass of DecimalField with a widget member set, like so:

class ParameterField(DecimalField):
    widget = ParameterWidget

This works in Django 1.5 (by way of the constructor of Field, I guess). Django 1.6 doesn't pick up the specialised widget. IntegerField does a setdefault on widget that I can't follow:

class IntegerField(Field):
...

    def __init__(self, max_value=None, min_value=None, *args, **kwargs):
        self.max_value, self.min_value = max_value, min_value
        kwargs.setdefault('widget', NumberInput if not kwargs.get('localize') else self.widget)
        super(IntegerField, self).__init__(*args, **kwargs)

Adding localize = False to the ParameterField class doesn't help because that doesn't make it appear in kwargs for IntegerField.

Attachments (1)

22245-1.diff (1.8 KB ) - added by Claude Paroz 11 years ago.
Suggested fix

Download all attachments as: .zip

Change History (6)

comment:1 by Claude Paroz, 11 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

by Claude Paroz, 11 years ago

Attachment: 22245-1.diff added

Suggested fix

comment:2 by Claude Paroz, 11 years ago

Has patch: set

comment:3 by Simon Charette, 11 years ago

Triage Stage: AcceptedReady for checkin

Patch looks RFC.

comment:4 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 5a976b4bec79cdb6b75581be6478356fb13fda77:

Fixed #22245 -- Avoided widget overwrite in forms.IntegerField subclasses

Thanks Jeroen Pulles for the report and Simon Charette for the review.

comment:5 by Claude Paroz <claude@…>, 11 years ago

In 1a2939bc26b7077e3196cea9bce52826ec7a6d9d:

[1.6.x] Fixed #22245 -- Avoided widget overwrite in forms.IntegerField subclasses

Thanks Jeroen Pulles for the report and Simon Charette for the review.
Backport of 5a976b4bec7 from master.

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