Code

Opened 8 years ago

Closed 8 years ago

Last modified 6 years ago

#2421 closed defect (duplicate)

Error editing object in admin when it is the foreign key of another model twice, one of which is edited inline

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

Description

I will describe it by way of an example:

start with the following models:

class model_a(models.Model):
    title = models.CharField(maxlength=100)
    
    class Admin:
        pass
        
class model_b(models.Model):
    title = models.CharField(maxlength=100,core=True)
    fk1 = models.ForeignKey(model_a,edit_inline=models.TABULAR)
    fk2 = models.ForeignKey(model_a,related_name='other')
    
    class Admin:
        pass                

Notice that model_b has two fields that are foreign keys to the same model. Also, one of these foreign keys is edited inline. If you try to edit or add a model_a object in the admin side you will get a KeyError exception.

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by medhat

  • Resolution set to duplicate
  • Status changed from new to closed

duplicate of #2522

comment:2 Changed 6 years ago by shanx

which in turn is a duplicate of #1939

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.