layers Introducing Unfold components - Pre-made HTML blocks in Django admin for custom dashboards arrow_forward

To use ArrayWidget, you need to have unfold.contrib.forms in INSTALLED_APPS which is required dependency.

# settings.py

INSTALLED_APPS = [
    "unfold",
    "unfold.contrib.forms",
]

Below you can see how to use ArrayWidget in your admin class. In this example all ArrayField fields will use ArrayWidget to render input field. In case choices are provided for the widget, dropdown list will be used instead of text input.

# admin.py

from django.contrib import admin
from django.contrib.postgres.fields import ArrayField
from unfold.admin import ModelAdmin
from unfold.contrib.forms.widgets import ArrayWidget


@admin.register(MyModel)
class CustomAdminClass(ModelAdmin):
    formfield_overrides = {
        ArrayField: {
            "widget": ArrayWidget,
        }
    }

Be first to know about new features and updates

Each time something new happens in Unfold, like new major features or new design components, we'll send you a newsletter. We promise not to spam you.

Django admin theme built with Tailwind CSS to bring modern look and feel to your admin interface. Already contains several built-in features for smooth developer experience.

© 2023 - 2024 Created by unfoldadmin.com. All rights reserved.