Registry / web-framework / django-better-admin-arrayfield

django-better-admin-arrayfield

JSON →
library1.4.2pypypi✓ verified 84d ago

django-better-admin-arrayfield provides an enhanced widget for Django's `ArrayField` within the Django administration interface. It replaces the default comma-separated input with a more user-friendly list-based interface, allowing for dynamic addition and removal of items. The library is currently at version 1.4.2, last released in December 2020, and explicitly supports Python 3.5-3.8 and Django 2.0-3.1.

pip install django-better-admin-arrayfield
INSTALL
IMPORT
SIG · DJANGO-BETTER-ADMI
D
django-better-admin-arrayfield
web-frameworkpythonv1.4.2
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default_app_config
from django_better_admin_arrayfield import default_app_config
from django_better_admin_arrayfield.models.fields import ArrayField

To quickly integrate `django-better-admin-arrayfield`, add `django_better_admin_arrayfield` to your `INSTALLED_APPS` in `settings.py`. In your `models.py`, use `ArrayField` from `django_better_admin_arrayfield.models.fields`. Finally, in `admin.py`, apply the `DynamicArrayMixin` to your `ModelAdmin` class. This setup replaces the default `ArrayField` widget with the improved list-based interface in the Django admin.

import os import django from django.conf import settings from django.core.management import call_command # Minimal Django settings for quickstart if not settings.configured: settings.configure( DEBUG=True, INSTALLED_APPS=[ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.postgres', 'django_better_admin_arrayfield', 'my_app', ], DATABASES={ 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:', } }, TEMPLATES=[ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ], STATIC_URL='/static/', SECRET_KEY=os.environ.get('DJANGO_SECRET_KEY', 'a-very-secret-key-for-testing-only'), MIDDLEWARE_CLASSES=[ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ], ROOT_URLCONF='my_app.urls', ) django.setup() # my_app/models.py from django.db import models from django_better_admin_arrayfield.models.fields import ArrayField class TaggedItem(models.Model): name = models.CharField(max_length=255) tags = ArrayField(models.CharField(max_length=100), blank=True, default=list) def __str__(self): return self.name # my_app/admin.py from django.contrib import admin from django_better_admin_arrayfield.admin.mixins import DynamicArrayMixin from .models import TaggedItem @admin.register(TaggedItem) class TaggedItemAdmin(admin.ModelAdmin, DynamicArrayMixin): list_display = ('name', 'tags') # Example of custom subwidget if needed # from django_better_admin_arrayfield.forms.widgets import DynamicArrayTextareaWidget # formfield_overrides = { # ArrayField: {'widget': DynamicArrayTextareaWidget}, # } # my_app/urls.py from django.contrib import admin from django.urls import path urlpatterns = [ path('admin/', admin.site.urls), ] # Example of running migrations and creating a superuser (for testing admin access) if __name__ == '__main__': try: call_command('makemigrations', 'my_app') call_command('migrate') print("Django setup complete. Access admin at /admin/") except Exception as e: print(f"Error during Django setup: {e}") # You can now run the Django development server using: python manage.py runserver # (assuming you have a manage.py set up to use these settings)
Debug
Known issues
breakingThe library officially supports Django versions 2.0-3.1 and Python 3.5-3.8. Using it with newer Django (4.x+) or Python (3.9+) versions may lead to unexpected behavior or breakage due to unmaintained compatibility.
fix
Consider alternatives like `django-jsonform` or contributing to update the library for newer Django/Python versions. Thoroughly test existing functionality if upgrading.
affects: Django >= 3.2, Python >= 3.9
gotchaThe custom `ArrayField` widget may not render or function correctly within Django admin inlines. There are existing, unresolved issues related to inline support.
fix
Avoid using `django-better-admin-arrayfield` for `ArrayField` instances within admin inlines. Consider alternative UI approaches for such cases.
affects: All versions
gotchaAfter installation and adding to `INSTALLED_APPS`, the 'Add another' button for array items might not appear or function until static files are collected.
fix
Ensure you run `python manage.py collectstatic` in your deployment environment and development server (if relevant for static files serving).
affects: All versions
gotchaThe library requires additional steps and modifications to function correctly within the Wagtail CMS admin interface, primarily due to differences in static file loading and icon rendering.
fix
Refer to the GitHub issue `wagtail/wagtail#7182` for specific steps to integrate it with Wagtail admin, which involves custom templates and hooks.
affects: All versions when used with Wagtail
Upgrade
Version history
1.4.2latest on PyPI · released Dec 8, 2020
Audit
Dependencies
DjangorequiredCore framework dependency, specifically for `django.contrib.postgres.fields.ArrayField` integration.
psycopg2-binaryoptionalOften required for `ArrayField` which is typically used with PostgreSQL.
Agent activity
19 hits · last 30 days
node
18
Resources
django-better-admin-arrayfield — pip install django-better-admin-arrayfield · libregistry