Django

Code

Ticket #7947 (closed: fixed)

Opened 4 months ago

Last modified 3 months ago

Can't edit OneToOneField fields.

Reported by: tyson Assigned to: brosner
Milestone: 1.0 Component: Uncategorized
Version: SVN Keywords: OneToOneField ModelInheritance editable parent_link
Cc: chris@moffitts.net, bronger@physik.rwth-aachen.de, josh@joshuajonah.com, rokclimb15@gmail.com Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 1 Patch needs improvement: 0

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

2145-one-to-one-field_editable.diff (0.6 kB) - added by tyson on 07/24/08 19:48:12.
Patch to allow editing of OneToOneFields?
7947-one-to-one-field_editable.diff (0.6 kB) - added by rokclimb15 on 08/21/08 23:29:27.
Modified patch to cleanly apply to trunk code

Change History

07/24/08 19:48:12 changed by tyson

  • attachment 2145-one-to-one-field_editable.diff added.

Patch to allow editing of OneToOneFields?

07/24/08 19:50:56 changed by tyson

  • needs_better_patch changed.
  • has_patch set to 1.
  • needs_tests set to 1.
  • needs_docs changed.

07/24/08 22:09:23 changed by tyson

s / R8033 / r8033

07/25/08 12:25:02 changed by programmerq

  • stage changed from Unreviewed to Accepted.

07/25/08 12:25:07 changed by programmerq

  • milestone set to 1.0.

07/29/08 00:36:29 changed by mtredinnick

  • needs_better_patch set to 1.

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.

08/01/08 11:40:27 changed 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?

08/13/08 14:46:10 changed by anonymous

  • cc set to crypie.

08/13/08 14:59:49 changed by anonymous

  • cc changed from crypie to chris@moffitts.net.

08/14/08 08:18:51 changed by Torsten Bronger <bronger@physik.rwth-aachen.de>

  • cc changed from chris@moffitts.net to chris@moffitts.net, bronger@physik.rwth-aachen.de.

08/21/08 12:01:20 changed by joshuajonah

  • cc changed from chris@moffitts.net, bronger@physik.rwth-aachen.de to chris@moffitts.net, bronger@physik.rwth-aachen.de, josh@joshuajonah.com.

08/21/08 16:18:46 changed by semenov

Please also check the discussion in #8241.

08/21/08 23:29:27 changed by rokclimb15

  • attachment 7947-one-to-one-field_editable.diff added.

Modified patch to cleanly apply to trunk code

08/21/08 23:31:36 changed by rokclimb15

  • cc changed from chris@moffitts.net, bronger@physik.rwth-aachen.de, josh@joshuajonah.com to chris@moffitts.net, bronger@physik.rwth-aachen.de, josh@joshuajonah.com, rokclimb15@gmail.com.
  • needs_better_patch deleted.

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.

08/22/08 12:39:23 changed 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.

08/22/08 13:03:04 changed 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.

08/22/08 14:27:27 changed by brosner

  • status changed from assigned to closed.
  • resolution set to fixed.

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


Add/Change #7947 (Can't edit OneToOneField fields.)




Change Properties
Action