A reusable Django package to add column toggle functionality in the Django admin interface.
Project description
Django Admin Column Toggle
Django Admin Column Toggle is a reusable Django package that adds column toggle functionality to the Django admin interface. This allows users to show or hide columns in the list view of the Django admin site.
Installation
-
Install the package:
With poetry
poetry add django-admin-column-toggle
With pip
pip install django-admin-column-toggle
-
Add 'column_toggle' to your `INSTALLED_APPS` setting in your Django project:
INSTALLED_APPS = [ ... 'column_toggle', ]
Usage
-
Import `ColumnToggleModelAdmin` from `column_toggle.admin` and inherit it in your `ModelAdmin` class. For example:
from django.contrib import admin from column_toggle.admin import ColumnToggleModelAdmin from .models import YourModel @admin.register(YourModel) class YourModelAdmin(ColumnToggleModelAdmin): list_display = ('field1', 'field2', 'field3')
-
To set the default selected columns, add the `default_selected_columns` attribute in your `ModelAdmin` class:
@admin.register(YourModel) class YourModelAdmin(ColumnToggleModelAdmin): list_display = ('field1', 'field2', 'field3') default_selected_columns = ['field1', 'field2']
By doing this, only the specified columns ('field1' and 'field2' in this example) will be visible by default. Users can still toggle the visibility of other columns manually.
-
That's it! Now you should have column toggle functionality in the Django admin list view for the specified model.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
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_admin_column_toggle-0.4.2.tar.gz
.
File metadata
- Download URL: django_admin_column_toggle-0.4.2.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.6 Linux/6.10.10-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffad9da0cc9d1173486430c3cb93075fed0cd24bde8c12e1653aeca2b3c2a279 |
|
MD5 | b8a663da52880e7510a69ac5bb1cf063 |
|
BLAKE2b-256 | 15e7ef70ddf048d5b24612b8acc3db294d24aa0a6b46be7d1216c7b5832f3c72 |
File details
Details for the file django_admin_column_toggle-0.4.2-py3-none-any.whl
.
File metadata
- Download URL: django_admin_column_toggle-0.4.2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.6 Linux/6.10.10-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62eaba6842ae923dd6dbbcecb885200636590e49fa57fab61e015ac602cb46f1 |
|
MD5 | f58f305fd5736fe6fa281aea506b743e |
|
BLAKE2b-256 | cf98fbe019014538f2d45e5bca68ba0364a401d23d29155d4d22c2f9c2cd59d0 |