Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#22954 closed Uncategorized (invalid)

Admin OneToOneField not shown on other side

Reported by: m@… 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 luto, 10 years ago

Cc: luto added

comment:2 by Tim Graham, 10 years ago

Resolution: invalid
Status: newclosed

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.

comment:3 by luto, 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 Tim Graham, 10 years ago

I would look at a patch, but I'm skeptical that it could be done simply.

Note: See TracTickets for help on using tickets.
Back to Top