[Answer]-Django admin filter widget in iOS

1đź‘Ť

âś…

This is a known bug that has been open for over two years:

https://code.djangoproject.com/ticket/14716

I think that until the bug gets fixed, you should either remove the widget for all devices or remove it for only iOS devices. I’ll assume you prefer the latter. I thought of a way to do it, but it’s very hacky. My idea is to monkey patch django.contrib.admin.widgets.FilteredSelectMultiple. You would change the JavaScript generated by its render method so that rather than having the JavaScript immediately call the addEvent function, it would call it only if the user agent doesn’t contain “iPad”, “iPhone”, or “iPod”. You may also need to override the updateSelectFilter functions defined in these files:

  1. django/contrib/admin/templates/admin/edit_inline/stacked.html
  2. django/contrib/admin/templates/admin/edit_inline/tabular.html

As I said, this solution is very hacky, but I’m not sure how any workaround to this problem could not be hacky.

👤Adam Taylor

Leave a comment