Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#7947 closed (fixed)

Can't edit OneToOneField fields.

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

Download all attachments as: .zip

Change History (18)

Changed 6 years ago by tyson

Patch to allow editing of OneToOneFields

comment:1 Changed 6 years ago by tyson

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

comment:2 Changed 6 years ago by tyson

s / R8033 / r8033

comment:3 Changed 6 years ago by programmerq

  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 6 years ago by programmerq

  • milestone set to 1.0

comment:5 Changed 6 years ago by mtredinnick

  • 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 6 years ago by brosner

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

  • Cc crypie added

comment:8 Changed 6 years ago by anonymous

  • Cc chris@… added; crypie removed

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

  • Cc bronger@… added

comment:10 Changed 6 years ago by joshuajonah

  • Cc josh@… added

comment:11 Changed 6 years ago by semenov

Please also check the discussion in #8241.

Changed 6 years ago by rokclimb15

Modified patch to cleanly apply to trunk code

comment:12 Changed 6 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 6 years ago by brosner

  • Owner changed from nobody to brosner
  • Status changed from new to assigned

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 6 years ago by brosner

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 6 years ago by brosner

  • Resolution set to fixed
  • Status changed from assigned to closed

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

comment:16 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.