jazzband / django-smart-selects

chained and grouped selects for django forms
https://django-smart-selects.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.1k stars 348 forks source link

Chaining not working in inlines in ChainedManyToManyField with horizontal=True parameter #350

Open KaktusOnFire opened 1 year ago

KaktusOnFire commented 1 year ago

Checklist

Put an x in the bracket when you have completed each task, like this: [x]

Steps to reproduce

  1. Create inline
  2. Add chainedmanytomany field with horizontal=True parameter
  3. Try to pick any of ProductGroup values

Actual behavior

Get chained values only for product and tariff p.s. everything works OK ONLY when i'm press save and trying to change EXISTING object image

Expected behavior

Get chained values for product, tariff and discounts

image

Model structure


    product_group = models.ForeignKey(ProductGroup, on_delete=models.RESTRICT, default=None, null=True)
    product = ChainedForeignKey(Product,
                                chained_field="product_group",
                                chained_model_field="product_group",
                                show_all=False,
                                auto_choose=True,
                                sort=True,
                                default=None
                                )
    tariff = ChainedForeignKey("Tariff",
                               chained_field="product_group",
                               chained_model_field="product_group",
                               show_all=False,
                               auto_choose=True,
                               sort=True,
                               default=None
                               )
    discounts = ChainedManyToManyField("Discount",
                                       chained_field="product_group",
                                       chained_model_field="product_groups",
                                       default=None,
                                       blank=True,
                                       )

Console log after picking ProductGroup value

2023-06-15 16:38:11 | INFO/MainProcess | "GET /chaining/filter/crm/Tariff/product_group/crm/UserInvoiceItem/tariff/68/ HTTP/1.1" 200 286
2023-06-15 16:38:11 | INFO/MainProcess | "GET /chaining/filter/crm/Product/product_group/crm/UserInvoiceItem/product/68/ HTTP/1.1" 200 1071

Log should contains request for discounts field, but its not.

KaktusOnFire commented 7 months ago

Any suggestions?