Opened 8 years ago

Closed 8 years ago

#4490 closed (duplicate)

edit_inline breaks when referencing the foreign key model twice

Reported by: James Punteney <punteney@…> Owned by: adrian
Component: contrib.admin Version: 0.96
Severity: Keywords: edit_inline
Cc: punteney@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Trying to use edit_inline where it references the foreign key model twice causes an error in the admin interface. This error will be thrown:

TypeError at /admin/test/list/add/
'bool' object is not callable
Request Method: 	GET
Request URL:
Exception Type: 	TypeError
Exception Value: 	'bool' object is not callable
Exception Location: 	C:\Python25\Lib\site-packages\django\db\models\ in bind, line 129

When you try to reference the foreign key model twice as in this code:

from django.db import models

class List(models.Model):
    name =models.CharField(maxlength=128)

    class Admin:

class Entry(models.Model):
    list = models.ForeignKey(List, edit_inline=models.TABULAR)
    name = models.CharField(maxlength=128, core=True)
    to = models.ForeignKey(List, null=True, blank=True, related_name='to')

This issue was also discussed on the mailing list here:

Change History (4)

comment:1 Changed 8 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Here's the relevant lines inside the RelatedObject class. 129 is the last line of:

    def bind(self, field_mapping, original, bound_related_object_class=BoundRelatedObject):
        return bound_related_object_class(self, field_mapping, original)

Looks like something's passing a bool into bind() as bound_related_object_class}} instead of passing a {{{BoundRelatedObject, as it should.

You may want to provide more of the stack trace, if you can.

comment:2 Changed 8 years ago by anonymous

Apologies for the poor WikiFormatting!

comment:3 Changed 8 years ago by John Shaffer <jshaffer2112@…>

Duplicate of #4126.

comment:4 Changed 8 years ago by Simon G. <dev@…>

  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top