django-sortedm2m-filter-horizontal-widget
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.9 | 1.2.1 |
| >= 2.0 | 1.3.2 |
| >= 3.0 | latest |
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
Release files for django-sortedm2m-filter-horizontal-widget 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_sortedm2m_filter_horizontal_widget-2.0.1.tar.gz | 39.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_sortedm2m_filter_horizontal_widget-2.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 81.7 kB
Release files / django_sortedm2m_filter_horizontal_widget-2.0.1.tar.gz
| Download URL | django_sortedm2m_filter_horizontal_widget-2.0.1.tar.gz |
|---|---|
| Size | 39.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ba2443fc813314a8e9ee9d76989744877a8b6998a26ea059df60ca66b996cd3
|
|
BLAKE2b-256 checksum How to use checksums |
9b4c4e58dd42793a092fbc31c616e1a8db2115297b16dc12de6e723fcea70391
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.8 Darwin/21.3.0
|
Release files / django_sortedm2m_filter_horizontal_widget-2.0.1-py3-none-any.whl
| Download URL | django_sortedm2m_filter_horizontal_widget-2.0.1-py3-none-any.whl |
|---|---|
| Size | 41.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8f8dab8861df3d06c5b58bedaaf47a3ecd7e54d24716589a6a3785afb779afff
|
|
BLAKE2b-256 checksum How to use checksums |
5b9e169586846c827509387c0f5bfb454c385c3a7ca67d10daa2d30af8f10512
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.8 Darwin/21.3.0
|