{{{
from django import forms
class Fields(forms.Form):
field = forms.ChoiceField(choices=(('one', 'one'), ('two', 'two')))
class Foo(Fields):
def __init__(self, *args, **kwargs):
super(Foo, self).__init__(*args, **kwargs)
self.fields['field'].widget.choices[0] = ('foo', 'foo')
class Bar(Fields):
pass
foo = Foo()
bar = Bar()
foo.fields['field'].widget.choices
>>>[('foo', 'foo'), ('two', 'two')]
bar.fields['field'].widget.choices
>>>[('foo', 'foo'), ('two', 'two')]
}}}
Where foo and bar have nothing to do with one another.
A more simple example:
{{{
import copy
from django import forms
widget = forms.Select()
widget_copy = copy.deepcopy(widget)
widget.attrs is widget_copy.attrs
>>>False
widget.choices is widget_copy.choices
>>>True
}}}
Since we did a deepcopy the {{widget.choices is widget_copy.choices}}}
must have returned {{False}} yet it returned {{{True}}}.
--
Ticket URL: <https://code.djangoproject.com/ticket/25085>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => assigned
* needs_docs: => 0
* owner: => ericfc
* needs_tests: => 0
* needs_better_patch: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/25085#comment:1>
* Attachment "25085.diff" added.
Comment (by ericfc):
The pull request has been made:
https://github.com/django/django/pull/4965
--
Ticket URL: <https://code.djangoproject.com/ticket/25085#comment:2>
Old description:
New description:
{{{
from django import forms
class Bar(Fields):
pass
--
--
Ticket URL: <https://code.djangoproject.com/ticket/25085#comment:3>
* has_patch: 0 => 1
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/25085#comment:4>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/25085#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"8ee6a3f1a855bf983639a14fc2393baa8ead741f" 8ee6a3f]:
{{{
#!CommitTicketReference repository=""
revision="8ee6a3f1a855bf983639a14fc2393baa8ead741f"
Fixed #25085 -- Overrode Select widget's __deepcopy__()
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25085#comment:6>
Comment (by Tim Graham <timograham@…>):
In [changeset:"b356dc4e07915521db1e768d6357e3d982877a6e" b356dc4e]:
{{{
#!CommitTicketReference repository=""
revision="b356dc4e07915521db1e768d6357e3d982877a6e"
Refs #25085 -- Used more specific assertion in widget test.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25085#comment:7>