Django-grappelli: Django 2.1 breaks ManyToManyField widget

Created on 30 Aug 2018  ·  4Comments  ·  Source: sehmaschine/django-grappelli

With Grappelli 2.11.1, multiple select widget is broken when running with Django 2.1, but fine in Django 2.0.8. Multiple select widget can be find in Home > Authentication and Authorization > Users and look into Groups and User Permission.

In Django 2.0.8, the left-hand side box is a scrollable table. In Django 2.1, the box becomes a single row with a drop-down arrow (but it won't expand). It is scrollable in Safari but not in Chrome.

The issues affect Users admin to select groups and permissions, and any other admin page with ManyToManyField.

A deep comparison of Django 2.0.8 vs 2.1 reveals that the following line is changed and (may) cause the issue:

2.0.8 /django/forms/widgets.py LINE 679:
        context['widget']['attrs']['multiple'] = 'multiple'

2.1 /django/forms/widgets.py LINE 670:
        context['widget']['attrs']['multiple'] = True

A local test confirmed that, if revert the changes of above (True -> 'multiple'), the widget of ManyToManyField is back to normal.

A local test confirmed that, 2.1 without Grappelli does not suffer this problem (so I cannot file this as bug to djangoproject.com). Django has changed the value of attrs from text to boolean.

Most helpful comment

@Tusky Yeah, sorry. I've been on holidays. We'll do an update asap.

All 4 comments

This should already be fixed in 93057187caa4610f37984d25cc1efe74568fa9b1 (can you please check?)

Followed your fix, I modified my local copy: replacing "select[multiple=multiple]" with "select[multiple]" in two files:

  • grappelli/static/grappelli/stylesheets/rtl.css
  • grappelli/static/grappelli/stylesheets/screen.css
    And the problem is gone.

Since pipenv only grab 2.11.1, currently I will just leave it and wait for release of 2.11.2. Thanks.

Any plans on a hotfix release? I copied the CSS to overwrite with the fix, but would be better if I didn't have to do that :)

@Tusky Yeah, sorry. I've been on holidays. We'll do an update asap.

Was this page helpful?
0 / 5 - 0 ratings