#1939: [patch] edit_inline and Multiple ForeignKeys to same model breaks the 
admin
-------------------------------+--------------------------------------------
   Reporter:  [EMAIL PROTECTED]  |                Owner:  adrian         
     Status:  new              |            Component:  Admin interface
    Version:  SVN              |           Resolution:                 
   Keywords:                   |                Stage:  Accepted       
  Has_patch:  1                |           Needs_docs:  0              
Needs_tests:  1                |   Needs_better_patch:  0              
-------------------------------+--------------------------------------------
Comment (by [EMAIL PROTECTED]):

 In django 0.96, I'm getting a different exception in this case:
 
 {{{
 Traceback (most recent call last):
 File "/var/lib/python-support/python2.5/django/template/__init__.py" in
 render_node
   723. result = node.render(context)
 File "/var/lib/python-support/python2.5/django/template/defaulttags.py" in
 render
   122. nodelist.append(node.render(context))
 File "/var/lib/python-
 support/python2.5/django/contrib/admin/templatetags/admin_modify.py" in
 render
   170. bound_related_object = relation.bind(context['form'], original,
 bound_related_object_class)
 File "/var/lib/python-support/python2.5/django/db/models/related.py" in
 bind
   129. return bound_related_object_class(self, field_mapping, original)
 
   TypeError at /admin/polls/poll/2/
   'bool' object is not callable
 }}}
 
 The direct reason is this
 (django/contrib/admin/templatetags/admin_modify.py, line 163-168):
 
 {{{
 if relation.field.rel.edit_inline == models.TABULAR:
   bound_related_object_class = TabularBoundRelatedObject
 elif relation.field.rel.edit_inline == models.STACKED:
   bound_related_object_class = StackedBoundRelatedObject
 else:
   bound_related_object_class = relation.field.rel.edit_inline
 }}}
 
 When called on an object without edit_inline set, "edit_inline" is
 implicitly False, so bound_related_object_class is set to False, which is
 not callable.
 
 I've attached a much less invasive patch, which takes the fields without
 edit_inline out of the related fields list *only* when that list is being
 passed to the admin template to be rendered inline.  I don't know how this
 interacts with the first patch, but I prefer mine because the first patch
 strikes me as dangerous - it takes edit_inline into account at too low a
 level.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/1939#comment:10>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to