Django

Code

Ticket #4126 (closed: worksforme)

Opened 1 year ago

Last modified 3 months ago

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

Reported by: dan <goldner@alum.mit.edu> Assigned to: nobody
Milestone: Component: django.contrib.admin
Version: SVN Keywords: m2m intermediary edit_inline
Cc: smoonen@andstuff.org Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

Attachments

Change History

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

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

This is the same bug as #4490.

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

  • owner changed from jacob to adrian.
  • component changed from Uncategorized to Admin interface.

11/22/07 11:19:48 changed by Antonis Christofides <anthony@itia.ntua.gr>

  • keywords changed from m2m intermediary to m2m intermediary edit_inline.

02/27/08 19:40:37 changed by jacob

  • stage changed from Unreviewed to Accepted.

05/09/08 06:54:16 changed by Scott Moonen <smoonen@andstuff.org>

  • cc set to smoonen@andstuff.org.

07/19/08 22:05:52 changed by smoonen@andstuff.org

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

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!


Add/Change #4126 (TypeError when edit_inline and Multiple ForeignKeys to same model breaks the admin)




Change Properties
Action