2

Personally I don't think Django's built-in widget for ManyToManyField relationship is particularly good. Especially when it comes down to use it on an iPad, the widget is neither intuitive nor practical (you have no ctrl button to hold down to multi select).

enter image description here

So I am battling this issue now for one week, trying to make a formset with forms that include each a dropdown.

enter image description here

My attempts to achieve the solution above, have also been fruitless so far.

So I thought maybe its a good time to take a step back and ask the community: What would you do in my shoes? If you were given a requirement like this, how would you replace the M2M widget? What options do I have?

I just found out about the admin M2M widget according to this question on Stackoverflow.

django.contrib.admin.widgets.FilteredSelectMultiple

It is a bit big and not very pretty, but would do the job. I have found this tutorial and followed every step. But the widget is still showing as a plain M2M widget instead of the admin one. The css and js are loaded correctly (no indication of 404) but still the old widget shows up.

Many Thanks,

Community
  • 1
  • 1
Houman
  • 64,245
  • 87
  • 278
  • 460
  • I think you should try this [library](http://harvesthq.github.com/chosen/) with `django-chosen` integration. – rafek Aug 17 '12 at 13:45
  • @rafek This could be indeed the answer to my prayers. Thanks a lot for sharing this. I have installed `django-chosen` extension by PIP successfully, however when I try to import `from chosen import forms as chosenforms` it throws an error. It doesn't see it. Any idea why? The documentation doesn't mention any other setup steps. – Houman Aug 17 '12 at 18:11
  • @rafek I have some great news. I ended up using the chosen jquery directly and it works like a charm. Later last night I finally got in touch with someone from django-chosen. For whatever reason do not install it the way they suggest it in the documentation as it didn't work for me : `$ pip install -e git+git://github.com/theatlantic/django-chosen.git#egg=django-chosen`. I tried this three times without luck. However the plain `pip install django-chosen` worked for me right away. I am no PIP expert don't know why. Anyway please put this as an answer and I tick it off. Many Thanks!! – Houman Aug 18 '12 at 10:34
  • I'm really glad that you find this helpful. I usually include libraries as `django-chosen` to my project directly. It could help avoid versioning issues etc. Best solution is using virtualenv for each project I think. – rafek Aug 20 '12 at 06:14

1 Answers1

1

Try using chosen library. You can download it from here: http://harvesthq.github.com/chosen/.

To integrate it with django try django-chosen application. You could install it from PIP or directly download sources from github.

rafek
  • 635
  • 5
  • 8