I have a tough problem representing my data model
with Django when using the standard Admin Interface.

I need to represent the concept of a callgroup: a list
of items (either persons or, again, callgroups) to
which phone calls should be dispatched in a given sequence.
The model is illustrated at the end of this mail.

However, when I try to use the Admin interface it seems to get
confused:

1. If I set editable=False in callgroup_owner the Admin interface
gets confused because there are two foreign keys from CallgroupItem
to Callgroup: callgroup_owner and callgroup_member. In fact the
Admin interface shows a TABULAR list of Callgroup items and, also,
a STACKED list (however, only one should be shown).

2. If I set editable=True in callgroup_owner when I try to Add a new
callgroup I get KeyError exception with the following offending
template line:

   {% for related_object in inline_related_objects %} ...

I'm using version 0.96-pre of Django.

It seems that Django has some serious restrictions when there are
two foreign keys pointing to the same Model and one of them has
the edit_inline attribute set.

Does anyone have any idea of if/what I'm doing wrong? Is this a bug in
Django and I should report it?

=== My models.py file ===

class Person (models.Model):
    name = models.CharField(maxlength=15)

class Callgroup (models.Model):
    name = models.CharField(maxlength=15)
    class Admin:
        pass

class CallgroupItem (models.Model):
    sequence = models.IntegerField(core=True)

    # Owner of this callgroup item
    callgroup_owner = models.ForeignKey(Callgroup,
            related_name="callgroup_owner",
            editable=False, # Error even if True
            edit_inline=models.TABULAR,
            )

    # Callgroup to be called (if not NULL)
    callgroup_member = models.ForeignKey(Callgroup,
            related_name="callgroup_member",
            null=True, blank=True,
            )
    # Person to be called (if not NULL)
    person_member = models.ForeignKey(Person,
            related_name="person_member",
            null=True, blank=True
            )

-- 
Mario Graziosi, mailto:[EMAIL PROTECTED]
FG&A srl (http://www.fgasoftware.com/)
[EMAIL PROTECTED]: The agile PBX (http://www.voiceatwork.eu/)
Tel: 02 9350-4780 interno 101, Fax: 02 9350-0178


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