#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)
Change History (18)
by , 17 years ago
| Attachment: | 2145-one-to-one-field_editable.diff added |
|---|
comment:1 by , 17 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
comment:3 by , 17 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:4 by , 17 years ago
| milestone: | → 1.0 |
|---|
comment:5 by , 17 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 , 17 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 , 17 years ago
| Cc: | added |
|---|
comment:8 by , 17 years ago
| Cc: | added; removed |
|---|
comment:9 by , 17 years ago
| Cc: | added |
|---|
comment:10 by , 17 years ago
| Cc: | added |
|---|
by , 17 years ago
| Attachment: | 7947-one-to-one-field_editable.diff added |
|---|
Modified patch to cleanly apply to trunk code
comment:12 by , 17 years ago
| Cc: | 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 , 17 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → 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 by , 17 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 , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Patch to allow editing of OneToOneFields