Skip to main content

Django admin widget for Gregor Mülleggers django-sortedm2m_ library

Project description

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

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

Built Distribution

File details

Details for the file django_sortedm2m_filter_horizontal_widget-2.0.1.tar.gz.

File metadata

File hashes

Hashes for django_sortedm2m_filter_horizontal_widget-2.0.1.tar.gz
Algorithm Hash digest
SHA256 2ba2443fc813314a8e9ee9d76989744877a8b6998a26ea059df60ca66b996cd3
MD5 9562d50ffb75be1facda5c3bb64a0c07
BLAKE2b-256 9b4c4e58dd42793a092fbc31c616e1a8db2115297b16dc12de6e723fcea70391

See more details on using hashes here.

File details

Details for the file django_sortedm2m_filter_horizontal_widget-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_sortedm2m_filter_horizontal_widget-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f8dab8861df3d06c5b58bedaaf47a3ecd7e54d24716589a6a3785afb779afff
MD5 e92cea25b49006f01a7682209af65ffb
BLAKE2b-256 5b9e169586846c827509387c0f5bfb454c385c3a7ca67d10daa2d30af8f10512

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page