A searchable, filterable data-table checkbox widget for Django Admin to make ManyToManyField selection efficient, allowing searches by multiple properties, not just by name.
Project description
django-admin-table-widget
A searchable, filterable data-table checkbox widget for Django Admin to make M2M (ManyToManyField) field selection efficiently, so it can be searchable not by name only, but by multiple columns simultaneously.
The Problem
Django's default admin interface provides a <select multiple> box for ManyToMany fields. While you can use filter_horizontal to get a dual-list box, there is no built-in way to display related items as a rich data table with custom columns, colored badges, inline textual search, and column-specific dropdown filters.
If you have a form with a complex M2M relationship where the admin user needs to pick items based on multiple properties (e.g. status, type, platform), the standard widgets fall short.
The Solution
django-admin-table-widget provides a drop-in TableListingWidget that replaces the default M2M widget with a robust, client-side searchable and filterable table.
(Replace
screenshot.png with an actual screenshot of the widget in action!)
Installation
pip install django-admin-table-widget
Ensure it's in your INSTALLED_APPS so Django can find the widget templates (optional but recommended):
INSTALLED_APPS = [
# ...
'django_admin_table_widget',
]
Usage
Define your columns using ListingColumn and pass them to the TableListingWidget:
from django import forms
from django.contrib import admin
from django_admin_table_widget.widgets import ListingColumn, TableListingWidget
from .models import MyModel, RelatedItem
MY_COLUMNS = [
ListingColumn("id", "ID", searchable=True),
ListingColumn("name", "Name", searchable=True),
ListingColumn("type", "Type", value=lambda obj: obj.get_type_display(), filterable=True),
ListingColumn("is_active", "Status", badge=True, filterable=True),
]
class MyModelForm(forms.ModelForm):
items = forms.ModelMultipleChoiceField(
queryset=RelatedItem.objects.all(),
widget=TableListingWidget(columns=MY_COLUMNS),
required=False,
)
class Meta:
model = MyModel
fields = '__all__'
@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
form = MyModelForm
Read-Only Display
You can also use this widget to render a read-only table in your admin display methods (no checkboxes):
from django_admin_table_widget.widgets import render_listing_table
@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
readonly_fields = ('items_table',)
def items_table(self, obj):
return render_listing_table(MY_COLUMNS, obj.items.all(), name="items")
items_table.short_description = "Items"
Compatibility
- Highly compatible with third-party admin themes like Django Jet and Jazzmin. It binds to all available jQuery instances and native DOM events to ensure filters always work.
- Inlines its CSS/JS for zero-configuration static file deployment (no need to run
collectstaticfor the widget to work).
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_admin_table_widget-0.1.0.tar.gz.
File metadata
- Download URL: django_admin_table_widget-0.1.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb4663d2d0f6ef279c28bef7c784e75f834b65fa68cd05b023ba86c4b6a556be
|
|
| MD5 |
c11397ba335fc5523c9f5cd90f1f9644
|
|
| BLAKE2b-256 |
d01fceef337aa4521286580e9d1faaedb0be484850d7a9abed1445e4e84fd938
|
File details
Details for the file django_admin_table_widget-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_admin_table_widget-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c720bd7afa264063b710026ba595ad30d0f8ccae758969fff7510041b8f853e8
|
|
| MD5 |
535c5b93bafea6f2a693e4f7d39c6444
|
|
| BLAKE2b-256 |
a98e8b0271ed6c5133a11a399474938ba1b181b96739eeab96f815bf255ee06a
|