Is there a simple way to show a ManyToManyField as Checkboxes in Django Admin?? Any suggestions?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
- Evil ctypes hack in python
To override for a single field the following is useful:
From this answer it seems like it is possible to use ModelAdmin.formfield_overrides to override the ManyToManyField to use CheckBoxSelectMultiple:
I haven't tried it and am merely quoting from the source, but it seems plausible. Good luck.
Warning: as @errx rightly pointed out, the documentation highlights the following caveat:
This is most certainly possible. Here is the code which you can place in the
ModelAdmin
subclass:This was derived from looking into the admin code.
I think there is no simple way to do this. You can try to override ModelAdmin class but this is not a "simple" way.
But you can use filter_horizontal or filter_vertical to add almost similar functionality
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.filter_horizontal