Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#7947 closed (fixed)

Can't edit OneToOneField fields.

Reported by: Tyson Clugg Owned by: Brian Rosner
Component: Uncategorized Version: dev
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: no UI/UX: no

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 16 years ago.
Patch to allow editing of OneToOneFields
7947-one-to-one-field_editable.diff (610 bytes ) - added by rokclimb15 16 years ago.
Modified patch to cleanly apply to trunk code

Download all attachments as: .zip

Change History (18)

by Tyson Clugg, 16 years ago

Patch to allow editing of OneToOneFields

comment:1 by Tyson Clugg, 16 years ago

Has patch: set
Needs tests: set

comment:2 by Tyson Clugg, 16 years ago

s / R8033 / r8033

comment:3 by Jeff Anderson, 16 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Jeff Anderson, 16 years ago

milestone: 1.0

comment:5 by Malcolm Tredinnick, 16 years ago

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 by Brian Rosner, 16 years ago

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 by anonymous, 16 years ago

Cc: crypie added

comment:8 by anonymous, 16 years ago

Cc: chris@… added; crypie removed

comment:9 by Torsten Bronger <bronger@…>, 16 years ago

Cc: bronger@… added

comment:10 by joshuajonah, 16 years ago

Cc: josh@… added

comment:11 by Ilya Semenov, 16 years ago

Please also check the discussion in #8241.

by rokclimb15, 16 years ago

Modified patch to cleanly apply to trunk code

comment:12 by rokclimb15, 16 years ago

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 by Brian Rosner, 16 years ago

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 by Brian Rosner, 16 years ago

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 by Brian Rosner, 16 years ago

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

milestone: 1.0

Milestone 1.0 deleted

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