AttributeError in admin when sub-classing ConfigurableProduct

Create issue
Issue #945 new
anentropic created an issue

I have been developing a custom product model. I originally developed as a standalone model as described in the docs but this meant that a 'product' consisted of three models: (stachmo) Product, ConfigurableProduct and my CTProduct model.

Everything worked fine but the admin was cumbersome.

I decided to try making my model as a sub-class of ConfigurableProduct. Now if I go to create/edit a new (satchmo) Product I get:

TemplateSyntaxError at /admin/product/product/7/ ... AttributeError: 'Product' object has no attribute 'ctproduct'

The problem seems to be in the 'get_subtypes' method of the Product model, around line #1004:

{{{

!python

try: subclass = getattr(self, subtype.lower()) gettype = getattr(subclass, '_get_subtype') subtype = gettype() if not subtype in types: types.append(subtype) except models.ObjectDoesNotExist: pass

}}} At first glance it seems to me that the code as-it-is is catching the wrong exception (one that would never occur). Maybe no-one's noticed because the try doesn't normally fail, but now my sub-classed model is exercising it for some reason.

I changed the try block to except AttributeError and the form loads and shows my 'add' link in the subtypes... nothing seems broken when I do that, so I think perhaps this is the fix?

Comments (2)

  1. Log in to comment