Horizontal filter widget for django-sortedm2m
Project description
sortedm2m-filter-horizontal-widget is an admin widget for Gregor Mülleggers excellent django-sortedm2m library.
This allows for a familiar filter horizontal widget.
Installation
pip install django-sortedm2m-filter-horizontal-widget
What version do I need?
Django |
Install |
---|---|
< 1.8 |
0.2 |
1.8 |
1.1 |
> 1.8 |
dev |
Usage
Add sortedm2m_filter_horizontal_widget to your INSTALLED_APPS. (needed for static files)
In your ModelAdmin add the following function to override the default widget.
from sortedm2m_filter_horizontal_widget.forms import SortedFilteredSelectMultiple class MyModelAdmin(admin.ModelAdmin): # ... def formfield_for_manytomany(self, db_field, request=None, **kwargs): if db_field.name == 'your_sortedm2m_field_name': kwargs['widget'] = SortedFilteredSelectMultiple() return super(MyModelAdmin, self).formfield_for_manytomany(db_field, request, **kwargs)
Todo
Automatically assign widget if field is specified in ModelAdmin’s filter_horizontal.
Add tests
Changelog
- 1.1:
Use admin_prefix to find image, in case user changes STATIC_URL setting Add version requirements per Django version
- 1.0:
Fixed bugs with popup closing. Added support for Django 1.10+
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for django-sortedm2m-filter-horizontal-widget-1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2093ca582dea79412a67b4aac15b217bcb67006c96e648e31a16a588d33a8261 |
|
MD5 | bd67ce9b6fac4704207bb0642ec801ca |
|
BLAKE2b-256 | f1ce3cf15361d2da5b0b5a5a7d591ae9d6ee4efe1ab3f238863846ba08327191 |