django-polymorphic icon indicating copy to clipboard operation
django-polymorphic copied to clipboard

error when tring to access a=children formset of a model

Open kimutaiRop opened this issue 5 years ago • 1 comments

I have a polymorphic model that I made and it has many child models which I want the users to be choosing dynamically, posting the first product has no issue, I was able to select the form to send to the user, however when I try subsequent queries for the model to send to user I get error

polymorphic.formsets.models.UnsupportedChildType: The 'ShirtsAndBlouseForm' found a 'PhoneTablets' model in the queryset, but no form class is registered to display it. my forms look like this

PhonesTabsForm = polymorphic_modelformset_factory(Product, fields=product_fields, formset_children=(
    PolymorphicFormSetChild(PhoneTablets, fields=product_fields + ['screen_size', 'battery_type',
                                                                   'battery_capacity', 'ram_measure', 'ram_storage',
                                                                   'internal_storage']),
))
ShirtsAndBlouseForm = polymorphic_modelformset_factory(Product, fields=product_fields, formset_children=(
    PolymorphicFormSetChild(ShirtsAndBlouse, fields=product_fields + ['techniques',
                                                                      'fit_type', 'length', 'material', 'fabric_type',
                                                                      'wear_type', 'design'], ),
))

I dont understand what could be happening that it can allow me to select the form during the first time but not the second time when product exist in the database

kimutaiRop avatar Oct 23 '19 11:10 kimutaiRop

I had the same issue as I forgot to include the child class (StackedPolymorphicInline.Child) in the inline (StackedPolymorphicInline).

lukatavcer avatar Feb 08 '21 22:02 lukatavcer