Opened 17 years ago

Closed 17 years ago

#4490 closed (duplicate)

edit_inline breaks when referencing the foreign key model twice

Reported by: James Punteney <punteney@…> Owned by: Adrian Holovaty
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: no UI/UX: no

Description

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: 	http://127.0.0.1:8000/admin/test/list/add/
Exception Type: 	TypeError
Exception Value: 	'bool' object is not callable
Exception Location: 	C:\Python25\Lib\site-packages\django\db\models\related.py 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:
        pass

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: http://groups.google.com/group/django-users/browse_frm/thread/8a42d9329c0920cb/211b1cd7b78be471

Change History (4)

comment:1 by anonymous, 17 years ago

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 by anonymous, 17 years ago

Apologies for the poor WikiFormatting!

comment:3 by John Shaffer <jshaffer2112@…>, 17 years ago

Duplicate of #4126.

comment:4 by Simon G. <dev@…>, 17 years ago

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top