Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#8694 closed (fixed)

Change page for model with a OneToOne field doesn't display related field value

Reported by: kmtracey Owned by: brosner
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This ticket is an attempt to state one simple re-creatable problem so as to simplify the tangled issues raised in #8241 and #8562.

Given these models:

from django.db import models

# Create your models here.
class Parent(models.Model):
    name = models.CharField(max_length=50)
    def __unicode__(self):
        return self.name

class Child(models.Model):
    name = models.CharField(max_length=50)
    parent = models.OneToOneField(Parent, primary_key=True)
    def __unicode__(self):
        return '%s, child of %s' % (self.name, unicode(self.parent))

and this admin.py:

from django.contrib import admin
from inlinet1.models import Parent, Child

class ParentAdmin(admin.ModelAdmin):
    list_display = ('name',)

class ChildAdmin(admin.ModelAdmin):
    list_display = ('name', 'parent',)

admin.site.register(Parent, ParentAdmin)
admin.site.register(Child, ChildAdmin)

From the admin:

1 - Select Add on Parents, fill in name, save

2 - Select Add on Childs, fill in name, select parent from 1, select "Save and continue editing"

On re-display of the change page, the select box widget for 'Parent' will be set to '-----'. This was introduced by the fix for #7888 and may be fixed by one of the patches on #8241, Brian understands that better than I.

Attachments (0)

Change History (4)

comment:1 Changed 6 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 6 years ago by brosner

  • Owner changed from nobody to brosner
  • Status changed from new to assigned

comment:3 Changed 6 years ago by brosner

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in [8756].

comment:4 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.