chrisglass/django_polymorphic — pull request #69 by borgstrom (2014-03-13 20:44:12+00:00)
Title: Prevent infinite recursion in Django 1.6

Using the polymorphic admin with Django 1.6 yields the following error for me:

...
File "/home/vagrant/virtualenv/lib/python2.6/site-packages/polymorphic/admin.py" in get_form
412. return super(PolymorphicChildModelAdmin, self).get_form(request, obj, **kwargs)
File "/home/vagrant/virtualenv/lib/python2.6/site-packages/django/contrib/admin/options.py" in get_form
503. fields = flatten_fieldsets(self.get_fieldsets(request, obj))
File "/home/vagrant/virtualenv/lib/python2.6/site-packages/polymorphic/admin.py" in get_fieldsets
478. other_fields = self.get_subclass_fields(request, obj)
File "/home/vagrant/virtualenv/lib/python2.6/site-packages/polymorphic/admin.py" in get_subclass_fields
497. form = self.get_form(request, obj, exclude=exclude)
File "/home/vagrant/virtualenv/lib/python2.6/site-packages/polymorphic/admin.py" in get_form
412. return super(PolymorphicChildModelAdmin, self).get_form(request, obj, **kwargs)
File "/home/vagrant/virtualenv/lib/python2.6/site-packages/django/contrib/admin/options.py" in get_form
503. fields = flatten_fieldsets(self.get_fieldsets(request, obj))
File "/home/vagrant/virtualenv/lib/python2.6/site-packages/polymorphic/admin.py" in get_fieldsets
478. other_fields = self.get_subclass_fields(request, obj)
File "/home/vagrant/virtualenv/lib/python2.6/site-packages/polymorphic/admin.py" in get_subclass_fields
497. form = self.get_form(request, obj, exclude=exclude)
File "/home/vagrant/virtualenv/lib/python2.6/site-packages/polymorphic/admin.py" in get_form
412. return super(PolymorphicChildModelAdmin, self).get_form(request, obj, **kwargs)

Exception Type: RuntimeError at /admin/fluent_pages/page/3/
Exception Value: maximum recursion depth exceeded in cmp

This is due to the changes in the way the django `get_form` function handles `fields`. In 1.5 it simply inspected `self.declared_fieldsets` but in 1.6 it now calls `self.get_fieldsets()`, which results in recursion.