#1681 closed defect (fixed)
[patch][magic-removal] Admin display for OneToOneField is broken
Reported by: | jkocherhans | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | contrib.admin | Version: | magic-removal |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
OneToOneField
(without raw_id_admin=True
) should have an html select field as an input widget in the admin system, but it's using a text input. The input's value attibute is empty on the change form as well.
Also, if even if you do use raw_id_admin-True
, the value attribute of the input tag is empty on the change form.
I think a couple of methods from ForeignKey
ought to be moved up to the RelatedField
class so OneToOneField
inherits them as well... I'll look into this more.
from django.contrib.auth.models import User from django.contrib.sites.models import Site class UserSite(models.Model): user = models.OneToOneField(User) # admin broken w/ or w/o raw_id_admin=True site = models.ForeignKey(Site)
Attachments (1)
Change History (7)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
After a little more research, here's what the current docs in the trunk and in magic-removal say about the issue:
- No
Place
selection interface is displayed onRestaurant
pages. There will be one (and only one)Restaurant
for eachPlace
.
- On the
Restaurant
change list, everyPlace
-- whether it has an associatedRestaurant
or not -- will be displayed. Adding aRestaurant
to aPlace
just means filling out the requiredRestaurant
fields.
Neither m-r or the trunk currently match either of those behaviors. Posting the issue to django-dev for feedback.
comment:3 by , 19 years ago
Summary: | [magic-removal] Admin display for OneToOneField is broken → [patch][magic-removal] Admin display for OneToOneField is broken |
---|
I've added a patch that makes OneToOneField
s read-only when you edit them in the admin system. They also behave like ForeignKey
fields when adding. raw_id_admin also works. Still no responses on the list... I'll probably apply this in the next couple of days unless I hear from someone.
Also, anyone know why patches (like the current one) don't get the pretty Trac formatting somtimes?
by , 19 years ago
Attachment: | one_to_one.diff added |
---|
comment:4 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Adding
ForeignKey
'sprepare_field_objs_and_params
method toOneToOneField
fixes the display issues. However, if you change the value of theOneToOneField
, the changes aren't saved via the admin interface, which got me thinking... should they be? I mean, it's fixable, but should you be able to change the value of aOneToOneField
? I thought you could in the trunk, but I forget.