Django

Code

Ticket #4490 (closed: duplicate)

Opened 1 year ago

Last modified 10 months ago

edit_inline breaks when referencing the foreign key model twice

Reported by: James Punteney <punteney@gmail.com> Assigned to: adrian
Milestone: Component: Admin interface
Version: 0.96 Keywords: edit_inline
Cc: punteney@gmail.com Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

Attachments

Change History

06/09/07 14:49:17 changed by anonymous

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

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.

06/09/07 14:50:14 changed by anonymous

Apologies for the poor WikiFormatting!

07/02/07 23:32:01 changed by John Shaffer <jshaffer2112@gmail.com>

Duplicate of #4126.

08/30/07 22:35:56 changed by Simon G. <dev@simon.net.nz>

  • status changed from new to closed.
  • resolution set to duplicate.

Add/Change #4490 (edit_inline breaks when referencing the foreign key model twice)




Change Properties
Action