id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 2522,Error when 2 foreign keys to same Model w/ edit_inline=True,mgraziosi@…,anonymous,"It seems that Django has some serious restrictions/bug when there are two foreign keys pointing to the same Model and one of them has the `edit_inline` attribute set. Suppose the following problem: a 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 ticket. When I try to use the Admin interface it seems to get confused: * 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). * 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. Following is the data model I used (`models.py`) to isolate and reproduce the bug: {{{ 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 ) }}} ",defect,closed,contrib.admin,0.95,blocker,duplicate,"graph, graphs, FormWrapper",Maniac@…,Unreviewed,0,0,0,0,0,0