﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29355	ArrayField in admin inline form try to save null instead default value	Irina Silvestrova	nobody	"I have buit-in `User` class and the `Employee` class, one-to-one with `User`. It has an `ArrayField` inside:
{{{
role = ArrayField(
    models.IntegerField(choices=UserRole.choices(), blank=True, null=True),
    verbose_name='User Roles', blank=True, default=list
)
}}}
It is not nullable, but has default value.

In admin, I have the class `EmployeeInline`:
{{{
class EmployeeInline(admin.StackedInline):
    model = models.Employee
    can_delete = False
    verbose_name_plural = 'employee'
}}}
And use it in the `UserAdmin` class in the following way:
{{{
@admin.register(models.User)
class UserAdmin(DefaultUserAdmin):
    def change_view(self, request, object_id, form_url='', extra_context=None):
        self.inlines = [EmployeeInline]
        return super(UserAdmin, self).change_view(
            request, object_id, form_url, extra_context
        )
}}}
I see role field correct on the admin page, but if I try to save the model without selected role, I have an error:
{{{
IntegrityError at /admin/auth/user/232/change/

null value in column ""role"" violates not-null constraint
DETAIL:  Failing row contains (232, , 232, , , , 31, t, f, null, null).
}}}"	Bug	closed	Uncategorized		Normal	needsinfo			Unreviewed	0	0	0	0	0	0
