Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#7947 closed (fixed)

Can't edit OneToOneField fields.

Reported by: Tyson Clugg Owned by: Brian Rosner
Component: Uncategorized Version: master
Severity: Keywords: OneToOneField ModelInheritance editable parent_link
Cc: chris@…, bronger@…, josh@…, rokclimb15@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

OneToOneField.init() forces editable=False, preventing editing of OneToOneFields using generated forms (including admin pages). This bug was introduced in R8033 in an attempt to get ModelInheritance working for admin pages. Patch attached, as was incorrectly attached to #2145 (which is a different issue altogether).

Attachments (2)

2145-one-to-one-field_editable.diff (610 bytes) - added by Tyson Clugg 8 years ago.
Patch to allow editing of OneToOneFields
7947-one-to-one-field_editable.diff (610 bytes) - added by rokclimb15 8 years ago.
Modified patch to cleanly apply to trunk code

Download all attachments as: .zip

Change History (18)

Changed 8 years ago by Tyson Clugg

Patch to allow editing of OneToOneFields

comment:1 Changed 8 years ago by Tyson Clugg

Has patch: set
Needs documentation: unset
Needs tests: set
Patch needs improvement: unset

comment:2 Changed 8 years ago by Tyson Clugg

s / R8033 / r8033

comment:3 Changed 8 years ago by Jeff Anderson

Triage Stage: UnreviewedAccepted

comment:4 Changed 8 years ago by Jeff Anderson

milestone: 1.0

comment:5 Changed 8 years ago by Malcolm Tredinnick

Patch needs improvement: set

This patch is correct, as far as it goes. However, it's not complete: if you actually create a pair of models with a non-primary-key one-to-one relation between them and view the one with the OneToOneField in the admin interface, there is a problem with a missing label. That should be corrected before we apply this.

comment:6 Changed 8 years ago by Brian Rosner

I also like to add that actually setting editable=False at all on a OneToOneField breaks in formsets. Perhaps this should be conditionalized in its formfield method determine whether to return some form field or None?

comment:7 Changed 8 years ago by anonymous

Cc: crypie added

comment:8 Changed 8 years ago by anonymous

Cc: chris@… added; crypie removed

comment:9 Changed 8 years ago by Torsten Bronger <bronger@…>

Cc: bronger@… added

comment:10 Changed 8 years ago by joshuajonah

Cc: josh@… added

comment:11 Changed 8 years ago by Ilya Semenov

Please also check the discussion in #8241.

Changed 8 years ago by rokclimb15

Modified patch to cleanly apply to trunk code

comment:12 Changed 8 years ago by rokclimb15

Cc: rokclimb15@… added
Patch needs improvement: unset

Malcolm,

I tested the situation you described in revision 8463, and my label shows up fine. I was able to save the object properly, so this patch appears to work. I tweaked the line numbers a little bit so it should apply cleanly against 8463, but this is Tyson's original patch.

comment:13 Changed 8 years ago by Brian Rosner

Owner: changed from nobody to Brian Rosner
Status: newassigned

I don't see the missing label either. However, the patch is correct, but I am testing it against the possible fix with #7888.

comment:14 Changed 8 years ago by Brian Rosner

I spoke too soon about it being the correct patch. I have a new patch that I will likely be committing to fix the issue in its entirety.

comment:15 Changed 8 years ago by Brian Rosner

Resolution: fixed
Status: assignedclosed

(In [8469]) Fixed #7947 -- Handle the display of OneToOneField in model forms correctly. Thanks tyson for the report and original patch.

comment:16 Changed 5 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

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