Better ArrayField widget for admin
Project description
Django better admin ArrayField
Better ArrayField widget for admin
Supported Python versions: 3.5, 3.6, 3.7 Supported Django versions: 1.11, 2.0, 2.1, 2.2
It changes comma separated widget to list based in admin panel.
Before:
After:
Quickstart
Install Django better admin ArrayField:
pip install django-better-admin-arrayfield
Add it to your `INSTALLED_APPS`:
INSTALLED_APPS = (
...
'django_better_admin_arrayfield.apps.DjangoBetterAdminArrayfieldConfig',
...
)
Usage
django_better_admin_arrayfield.models.fields.ArrayField
is a drop-in replacement for standard Django ArrayField
.
Import it like below and use it in your model class definition.
from django_better_admin_arrayfield.models.fields import ArrayField
Import DynamicArrayMixin like below
from django_better_admin_arrayfield.admin.mixins import DynamicArrayMixin
In your admin class add DynamicArrayMixin
:
...
class MyModelAdmin(admin.ModelAdmin, DynamicArrayMixin):
That's it.
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox
Pre-commit hooks
Install pre-commit black hook
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements_dev.txt
(myenv) $ pre-commit install
Credits
Inspired by: https://stackoverflow.com/a/49370480/4638248
Tools used in rendering this package:
History
1.0.3 (2019-09-02)
- Can add item after removing everything from the list
- Do not call static at startup time
1.0.2 (2019-04-03)
- If field is required empty list raises ValidationError on clean.
1.0.1 (2019-02-23)
- Empty list is no longer recognized as changed.
1.0.0 (2019-02-21)
- First release on PyPI.
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
Hashes for django-better-admin-arrayfield-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f10bd99cd0b4682a88e1b6c5ea9342fa69eb79450a064679f6620588ecb6a7fe |
|
MD5 | 099de366fbb857d88af80f8ebd187e99 |
|
BLAKE2b-256 | 10283ac9a1615a01e82e4fe394dba812661a61f115d672c8e5d0bbd5514696a7 |