burke-software / django-mass-edit

Make bulk changes in the Django admin interface
156 stars 68 forks source link

Weird compatibility issue with django-autocomplete-light #73

Open andreynovikov opened 6 years ago

andreynovikov commented 6 years ago

I have a weird compatibility issue with django-autocomplete-light. When I try to mass edit the following model Select button does nothing. Completely nothing. No messages, no errors in javascript console, nothing. I even tried to debug javascript code but it looks like submit action is never called. When I remove autocomplete_light.modelform_factory it starts working as intended. Weird is that I have another model which uses autocomplete_light form and it works nicely with mass edit.

Model:

class ProductRelation(models.Model):
    KIND_SIMILAR = 1
    KIND_ACCESSORY = 2
    KIND_GIFT = 3
    RELATIONSHIP_KINDS = (
        (KIND_SIMILAR, 'similar'),
        (KIND_ACCESSORY, 'accessory'),
        (KIND_GIFT, 'gift'),
        )
    parent_product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='parent_products')
    child_product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='child_products')
    kind = models.SmallIntegerField(choices=RELATIONSHIP_KINDS, default=KIND_SIMILAR, db_index=True)

Admin:

@admin.register(ProductRelation)
class ProductRelationAdmin(admin.ModelAdmin):
    list_display = ['parent_product', 'child_product', 'kind']
    list_display_links = ['parent_product', 'child_product']
    form = autocomplete_light.modelform_factory(ProductRelation, exclude=['fake'])