[Django] #29355: ArrayField in admin inline form try to save null instead default value

16 views
Skip to first unread message

Django

unread,
Apr 24, 2018, 7:26:04 AM4/24/18
to django-...@googlegroups.com
#29355: ArrayField in admin inline form try to save null instead default value
---------------------------------------------+------------------------
Reporter: Irina Silvestrova | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version:
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
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).
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29355>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 24, 2018, 11:31:30 AM4/24/18
to django-...@googlegroups.com
#29355: ArrayField in admin inline form try to save null instead default value
-----------------------------------+--------------------------------------

Reporter: Irina Silvestrova | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version:
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Tim Graham):

What version of Django are you using? Does the problem happen in non-
inline forms? I can't reproduce the issue there and I didn't try the
complete steps you offered.

--
Ticket URL: <https://code.djangoproject.com/ticket/29355#comment:1>

Django

unread,
May 4, 2018, 11:54:42 AM5/4/18
to django-...@googlegroups.com
#29355: ArrayField in admin inline form try to save null instead default value
-----------------------------------+--------------------------------------

Reporter: Irina Silvestrova | Owner: nobody
Type: Bug | Status: closed
Component: Uncategorized | Version:
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => needsinfo


Comment:

I tried to reproduce this and couldn't do so. The details are somewhat
sparse, perhaps you might provide a sample project.

--
Ticket URL: <https://code.djangoproject.com/ticket/29355#comment:2>

Reply all
Reply to author
Forward
0 new messages