#22954 closed Uncategorized (invalid)
Admin OneToOneField not shown on other side
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | 1.6 |
Severity: | Normal | Keywords: | admin, onetoone, one to one, relation, field |
Cc: | luto | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There are 2 models, Document and Episode. Episode has a OneToOneField to Document. When both are added to the admin-site, the relation shows up on Episode, but not on Document. Explicitly adding the field explicitly yields an "Unknown field"-exception.
Accessing the episode-attribute of Document in the code works just fine, of course.
This is the case in both 1.6 and 1.7.
Models:
from django.db import models class Document(models.Model): pass class Episode(models.Model): document = models.OneToOneField(Document, related_name='episode')
Admin:
from django.contrib import admin from .models import * class EpisodeAdmin(admin.ModelAdmin): pass class DocumentAdmin(admin.ModelAdmin): fields = ('episode',) admin.site.register(Episode, EpisodeAdmin) admin.site.register(Document, DocumentAdmin)
Change History (4)
comment:1 by , 10 years ago
Cc: | added |
---|
comment:2 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:3 by , 10 years ago
It being out of scope also means that you are not interested in this even as a contribution, right?
comment:4 by , 10 years ago
I would look at a patch, but I'm skeptical that it could be done simply.
Editing the reverse relation would require expanding the functionality of the admin to allow editing of two different models which I think is out of its scope. Note that you can view the reverse relation by adding it to
ModelAdmin.readonly_fields
.