Opened 18 years ago

Closed 16 years ago

#4126 closed (worksforme)

TypeError when edit_inline and Multiple ForeignKeys to same model breaks the admin

Reported by: dan <goldner@…> Owned by: nobody
Component: contrib.admin Version: dev
Severity: Keywords: m2m intermediary edit_inline
Cc: smoonen@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This is almost a duplicate of #1939, however, I am getting a TypeError instead of a KeyError.

Minimal example (a commenter to #2522 had the same use case in mind):

from django.db import models

class Node(models.Model):
    name = models.CharField('Name', maxlength=30, unique=True)   
    def __str__(self):
        return self.name
    class Admin:
        pass

class Link(models.Model):
    from_node=models.ForeignKey(Node, related_name='has_links_to', edit_inline=True)
    to_node=models.ForeignKey(Node, related_name='has_links_from', core=True)
    strength=models.FloatField('Strength', max_digits=3, decimal_places=2, core=True)

Trying to add a Node through the Admin gives this traceback (SVN r5061):

Traceback (most recent call last):
File "C:\cygwin\home\Dan\src\django_src\django\template\__init__.py" in render_node
  723. result = node.render(context)
File "C:\cygwin\home\Dan\src\django_src\django\template\defaulttags.py" in render
  125. nodelist.append(node.render(context))
File "C:\cygwin\home\Dan\src\django_src\django\contrib\admin\templatetags\admin_modify.py" in render
  170. bound_related_object = relation.bind(context['form'], original, bound_related_object_class)
File "C:\cygwin\home\Dan\src\django_src\django\db\models\related.py" in bind
  129. return bound_related_object_class(self, field_mapping, original)

  TypeError at /admin/ntwk/node/add/
  'bool' object is not callable

Change History (6)

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

This is the same bug as #4490.

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

Component: UncategorizedAdmin interface
Owner: changed from Jacob to Adrian Holovaty

comment:3 by Antonis Christofides <anthony@…>, 17 years ago

Keywords: edit_inline added

comment:4 by Jacob, 17 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Scott Moonen <smoonen@…>, 17 years ago

Cc: smoonen@… added

comment:6 by smoonen@…, 16 years ago

Resolution: worksforme
Status: newclosed

As expected, this is fixed with the merge of newforms-admin. I verified using my own models (I had to specify the 'fk_name' attribute on my inline class), and everything saves without error.

I am marking this as "worksforme" rather than "fixed" since I'm not the original reporter. Dan, feel free to move this ticket to "fixed", or alternatively the developers are welcome to do so as well.

Thanks!

Note: See TracTickets for help on using tickets.
Back to Top