#5505: Self-Referential ForeignKeys broken using newforms form_for_instance
with a
formfield_callback
-------------------------+--------------------------------------------------
Reporter: danlarkin | Owner: nobody
Status: new | Component: django.newforms
Version: SVN | Resolution:
Keywords: | Stage: Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------+--------------------------------------------------
Comment (by jkocherhans):
I'm fairly sure the problem I'm seeing, and the one danlarkin is reporting
are different now. I've tracked mine down to
{{{django.contrib.admin.widgets.RelatedFieldWrapper}}} which has a
reference to an {{{AdminSite}}} instance among other things, and deepcopy
just goes crazy from there trying to deepcopy all kinds of stuff.
{{{RelatedFieldWrapper}}} should probably be immutable, so the naive fix
is pretty simple.
However, other people writing custom fields and widgets are going to run
into this stuff eventually. I think {{{Widget}}} is probably the right
place to fix this though. By default, just do a copy, and let individual
widgets override {{{__deepcopy__}}} if they need to do something else.
@danlarkin: I have no idea why a form field would have a direct reference
to a db field (the one I saw was eventually getting there, but that was
about 5 levels deep). I'm wondering if the problem you're running into
needs to be stopped somewhere higher up the call chain.
And, if I'm talking out of my ass, I'm sure Malcolm will put me in my
place when he gets back. I'm not particularly confident in this
discussion.
--
Ticket URL: <http://code.djangoproject.com/ticket/5505#comment:7>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---