Django-jet: Possible problem with some many to many fields

Created on 19 Aug 2016  ·  14Comments  ·  Source: geex-arts/django-jet

I created a repository for shipping methods in django-oscar, so, i make the appropriate app and put this code in the admin:

from django.contrib import admin

from oscar.core.loading import get_model

OrderAndItemCharges = get_model('shipping', 'OrderAndItemCharges')
WeightBand = get_model('shipping', 'WeightBand')
WeightBased = get_model('shipping', 'WeightBased')


class OrderChargesAdmin(admin.ModelAdmin):
    filter_horizontal = [
        'countries',
    ]

    list_display = [
        'name',
        'description',
        'price_per_order',
        'price_per_item',
        'free_shipping_threshold'
    ]


class WeightBandInline(admin.TabularInline):
    model = WeightBand


class WeightBasedAdmin(admin.ModelAdmin):
    filter_horizontal = [
        'countries',
    ]

    list_display = [
        'code',
        'name',
        'default_weight'
    ]

    inlines = [WeightBandInline]


admin.site.register(OrderAndItemCharges, OrderChargesAdmin)
admin.site.register(WeightBased, WeightBasedAdmin)

So, i'll test the methods and i want add shipping countries for the existing methods.
problem

You can see here that change the country field isn't saved by the admin module, and add other country replace the existing country. This problem isn't present with the other fields. In Partner models there aren't problem to add users to a partner.

Other case is this:
seleccion_218
If a want delete one of theme, well, all are deleted, but, again, doesn't save the change.

out 04d
But, when i do this changes in the dashboard module, i haven't problem for update the methods.

Can anyone help me to explain this?

I can't see errors in the browser console, so, i don't know which problem here.

Most helpful comment

Same problem, with Django default user group permission, None of them being saved, can't add user group permission, neither user or group permission, I think the exact problem indicated on m2m

All 14 comments

Same problem, with Django default user group permission, None of them being saved, can't add user group permission, neither user or group permission, I think the exact problem indicated on m2m

@f1nality Big problem here.

I haven't tested with django-oscar yet, but I think the problem is that django-jet and django-oscar are using separate select2 instances. This conflict is causing this problem.

Which instance use django-jet?

I am having the same issue, but this is new. With previous versions, django-jet was stable and an awesome skin, now in the latest version has many bugs. I have created a project with only django and django-jet installed and it doesn't work.

I got the same issue without django-oscar.

In my case, any field which defined as filter_horizontal (such as user's permission), will cause admin won't save the changes correctly.

From django docs:

ModelAdmin.filter_horizontal

_By default, a ManyToManyField is displayed in the admin site with a