Can admin edit_inline a many2many relation to the same table via an
intermediary? How?

Example:

  party <- relation -> party,
  editing party & using edit_inlne for relation, django 0.95 admin
bombs.


Details:

Using this abridged model:
-----------------
from django.db import models

class Party(models.Model):
        name = models.CharField(maxlength=200)
        def __str__(self):
                return self.name
        class Admin: pass

class PartyRelationship(models.Model):
        party_relationship_type = models.CharField(maxlength=200, core=True)
        to_party = models.ForeignKey(Party, related_name='to_party_related',
edit_inline=True)
        from_party = models.ForeignKey(Party,
related_name='from_party_related', core=True)
        def __str__(self):
                return self.party_relationship_type
        class Admin: pass
----------------

I get a

 KeyError at /admin/test/party/add/
  'to_party'

when trying to create a party (traceback below).

>From what I gather (this being my 2nd day with django :), the admin
produces a FormFieldCollection _without_  the to_party, and then tries
to access that field.

(<FormFieldCollection: {'from_party': <FormFieldWrapper for
"partyrelationship.0.from_party">, 'party_relationship_type':
<FormFieldWrapper for "partyrelationship.0.party_relationship_type">,
'original': None, 'id': <FormFieldWrapper for
"partyrelationship.0.id">}>)

Since this works using three tables (party <- relation -> order) I'm
really puzzled. Should this work? Where can I start too look to make it
work? Where is this FormFieldCollection produced and why is to_party
ommited?


Traceback:

Traceback (most recent call last):
File
"/usr/local/lib/python2.4/site-packages/django/template/__init__.py" in
render_node
  706. result = node.render(context)
File
"/usr/local/lib/python2.4/site-packages/django/template/defaulttags.py"
in render
  118. nodelist.append(node.render(context))
File
"/usr/local/lib/python2.4/site-packages/django/contrib/admin/templatetags/admin_modify.py"
in render
  166. bound_related_object = relation.bind(context['form'], original,
bound_related_object_class)
File
"/usr/local/lib/python2.4/site-packages/django/db/models/related.py" in
bind
  126. return bound_related_object_class(self, field_mapping, original)
File
"/usr/local/lib/python2.4/site-packages/django/contrib/admin/templatetags/admin_modify.py"
in __init__
  147. self.form_field_collection_wrappers =
[FormFieldCollectionWrapper(field_mapping ,fields, i)
File
"/usr/local/lib/python2.4/site-packages/django/contrib/admin/templatetags/admin_modify.py"
in __init__
  123. self.bound_fields = [AdminBoundField(field, self.field_mapping,
field_mapping['original'])
File
"/usr/local/lib/python2.4/site-packages/django/contrib/admin/views/main.py"
in __init__
  112. self.form_fields = [field_mapping[name] for name in
self.field.get_manipulator_field_names('')]
File "/usr/local/lib/python2.4/site-packages/django/forms/__init__.py"
in __getitem__
  195. return self.formfield_dict[template_key]

  KeyError at /admin/test/party/add/
  'to_party'


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to