I'm following the m2m_intermediary pattern: 9. Many-to-many relationships via an intermediary table http://www.djangoproject.com/documentation/models/m2m_intermediary/
However, I need associations, not between two different models, but between pairs of instances of the *same* model, as discussed in this thread: Friendship_type on symmetrical M2M http://groups.google.com/group/django-users/browse_thread/thread/72afc8b5540dd75e/68688173a04a027d Take this Person model: class Person(models.Model): first_name = models.CharField(maxlength = 100) last_name = models.CharField(maxlength = 100) and associate pairs of persons, while adding some data: class Association(models.Model): person = models.ForeignKey(Person, related_name='friend_of') associate = models.ForeignKey(Person, related_name='friends') some_data = models.IntegerField() The admin interface for these models works correctly. Now, to be able to add Associations while editing Persons, I add edit_inline and core to Association fields. If I add them to both ForeignKey fields: class Association(models.Model): person = models.ForeignKey(Person, related_name='friend_of', core=True, edit_inline=models.TABULAR) associate = models.ForeignKey(Person, related_name='friends', core=True, edit_inline=models.TABULAR) dummy = models.IntegerField() I get this error: Traceback (most recent call last): File ".../django/template/__init__.py" in render_node 754. result = node.render(context) File ".../django/template/defaulttags.py" in render 134. nodelist.append(node.render(context)) File ".../django/contrib/admin/templatetags/admin_modify.py" in render 171. bound_related_object = relation.bind( context['form'], original, bound_related_object_class) File ".../django/db/models/related.py" in bind 129. return bound_related_object_class(self, field_mapping, original) File ".../django/contrib/admin/templatetags/admin_modify.py" in __init__ 138. for (i,field_mapping) in self.field_mappings.items() ] File ".../django/oldforms/__init__.py" in items 264. self.fill() File ".../django/oldforms/__init__.py" in fill 283. field = self.parent_manipulator[full_field_name] File ".../django/oldforms/__init__.py" in __getitem__ 28. raise KeyError, "Field %s not found\n%s" % ( field_name, repr(self.fields)) KeyError at /admin/person/add/ 'Field association.0.associate not found [FormField "first_name", FormField "last_name", FormField "association.0.id", FormField "association.0.person", FormField "association.0.dummy", FormField "association.1.id", FormField "association.1.person", FormField "association.1.dummy", FormField "association.2.id", FormField "association.2.person", FormField "association.2.dummy", FormField "association.0.id", FormField "association.0.person", FormField "association.0.dummy", FormField "association.1.id", FormField "association.1.person", FormField "association.1.dummy", FormField "association.2.id", FormField "association.2.person", FormField "association.2.dummy"]' If I only add edit_inline and core to the first ForeignKey field: class Association(models.Model): person = models.ForeignKey(Person, related_name='friend_of', core=True, edit_inline=models.TABULAR) associate = models.ForeignKey(Person, related_name='friends') dummy = models.IntegerField() I get this other error: Traceback (most recent call last): File ".../django/template/__init__.py" in render_node 754. result = node.render(context) File ".../django/template/defaulttags.py" in render 134. nodelist.append(node.render(context)) File ".../django/contrib/admin/templatetags/admin_modify.py" in render 171. bound_related_object = relation.bind( context['form'], original, bound_related_object_class) File ".../django/db/models/related.py" in bind 129. return bound_related_object_class(self, field_mapping, original) TypeError at /admin/diet/person/add/ 'bool' object is not callable What am I missing? -- Nicola Larosa - http://www.tekNico.net/ The smart way to keep people passive and obedient is to strictly limit the spectrum of acceptable opinion, but allow very lively debate within that spectrum. -- Noam Chomsky, quoted by David Icke, February 2007 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---