[Django] #28950: Model with OnetoOneFeild inline in admin cannot be created

7 views
Skip to first unread message

Django

unread,
Dec 20, 2017, 11:51:45 AM12/20/17
to django-...@googlegroups.com
#28950: Model with OnetoOneFeild inline in admin cannot be created
-----------------------------------------+------------------------
Reporter: tejinderss | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
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 models Foo and Bar for example:

class Foo(models.Model):
....

class Bar(models.Model):
foo = models.OneToOneField(Foo)
required_field = models.CharField(blank=False)


and in the admin.py i have:

class BarInline(admin.StackedInline):
model = Bar

@admin.register(Foo)
class FooAdmin(admin.ModelAdmin):
inlines = [BarInline]


Now the issue is on the save form in admin, if i try to create foo
instance without providing any bar data in barinline form, i get error
that bar's required field is required and if i make all fields optional,
it creates the bar instance anyway without any data. I have played with
min_num and max_num but in vain.

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

Django

unread,
Dec 20, 2017, 11:52:04 AM12/20/17
to django-...@googlegroups.com
#28950: Model with OnetoOneFeild inline in admin cannot be created
-------------------------------+--------------------------------------

Reporter: tejinderss | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
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
-------------------------------+--------------------------------------
Changes (by tejinderss):

* Attachment "Capture.PNG" added.

Django

unread,
Dec 20, 2017, 11:54:46 AM12/20/17
to django-...@googlegroups.com
#28950: Model with OnetoOneFeild inline in admin cannot be created
-------------------------------+--------------------------------------

Reporter: tejinderss | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
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
-------------------------------+--------------------------------------
Description changed by tejinderss:

Old description:

> I have models Foo and Bar for example:
>
> class Foo(models.Model):
> ....
>
> class Bar(models.Model):
> foo = models.OneToOneField(Foo)
> required_field = models.CharField(blank=False)
>

> and in the admin.py i have:
>
> class BarInline(admin.StackedInline):
> model = Bar
>
> @admin.register(Foo)
> class FooAdmin(admin.ModelAdmin):
> inlines = [BarInline]
>

> Now the issue is on the save form in admin, if i try to create foo
> instance without providing any bar data in barinline form, i get error
> that bar's required field is required and if i make all fields optional,
> it creates the bar instance anyway without any data. I have played with
> min_num and max_num but in vain.

New description:

I have models Foo and Bar for example:

class Foo(models.Model):
....

class Bar(models.Model):
foo = models.OneToOneField(Foo)
required_field = models.CharField(blank=False)


and in the admin.py i have:

class BarInline(admin.StackedInline):
model = Bar

@admin.register(Foo)
class FooAdmin(admin.ModelAdmin):
inlines = [BarInline]


Now the issue is on the save form in admin, if i try to create foo
instance without providing any bar data in barinline form, i get error
that bar's required field is required and if i make all fields optional,
it creates the bar instance anyway without any data. I have played with
min_num and max_num but in vain.

--

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

Django

unread,
Dec 20, 2017, 11:56:10 AM12/20/17
to django-...@googlegroups.com
#28950: Model with OnetoOneFeild inline in admin cannot be created
-------------------------------+--------------------------------------

Reporter: tejinderss | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
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
-------------------------------+--------------------------------------
Description changed by tejinderss:

Old description:

> I have models Foo and Bar for example:


>
> class Foo(models.Model):
> ....
>
> class Bar(models.Model):
> foo = models.OneToOneField(Foo)
> required_field = models.CharField(blank=False)
>

> and in the admin.py i have:
>
> class BarInline(admin.StackedInline):
> model = Bar
>
> @admin.register(Foo)
> class FooAdmin(admin.ModelAdmin):
> inlines = [BarInline]
>

> Now the issue is on the save form in admin, if i try to create foo
> instance without providing any bar data in barinline form, i get error
> that bar's required field is required and if i make all fields optional,
> it creates the bar instance anyway without any data. I have played with
> min_num and max_num but in vain.

New description:

I have models Foo and Bar for example:

{{{
class Foo(models.Model):
....

class Bar(models.Model):
foo = models.OneToOneField(Foo)
required_field = models.CharField(blank=False)
}}}

and in the admin.py i have:

{{{
class BarInline(admin.StackedInline):
model = Bar

@admin.register(Foo)
class FooAdmin(admin.ModelAdmin):
inlines = [BarInline]
}}}

Now the issue is on the save form in admin, if i try to create foo
instance without providing any bar data in barinline form, i get error
that bar's required field is required and if i make all fields optional,
it creates the bar instance anyway without any data. I have played with
min_num and max_num but in vain.

--

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

Django

unread,
Dec 20, 2017, 12:08:17 PM12/20/17
to django-...@googlegroups.com
#28950: Model with OnetoOneFeild inline in admin cannot be created
-------------------------------+--------------------------------------

Reporter: tejinderss | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
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):

I can't reproduce the issue given the minimal models and admin that you
provided.

--
Ticket URL: <https://code.djangoproject.com/ticket/28950#comment:3>

Django

unread,
Dec 21, 2017, 5:29:04 AM12/21/17
to django-...@googlegroups.com
#28950: Model with OnetoOneFeild inline in admin cannot be created
-------------------------------+--------------------------------------

Reporter: tejinderss | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
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
-------------------------------+--------------------------------------

Old description:

> I have models Foo and Bar for example:
>
> {{{
> class Foo(models.Model):
> ....
>
> class Bar(models.Model):
> foo = models.OneToOneField(Foo)
> required_field = models.CharField(blank=False)
> }}}
>
> and in the admin.py i have:
>
> {{{
> class BarInline(admin.StackedInline):
> model = Bar
>
> @admin.register(Foo)
> class FooAdmin(admin.ModelAdmin):
> inlines = [BarInline]
> }}}
>
> Now the issue is on the save form in admin, if i try to create foo
> instance without providing any bar data in barinline form, i get error
> that bar's required field is required and if i make all fields optional,
> it creates the bar instance anyway without any data. I have played with
> min_num and max_num but in vain.

New description:

I have models Foo and Bar for example:

{{{
from django.contrib.postgres.fields import ArrayField

class Foo(models.Model):
field = models.CharField(max_length=200)

class Bar(models.Model):
foo = models.OneToOneField(Foo)
required_field = models.CharField(blank=False)

array_field = ArrayField(models.CharField(max_length=50,
blank=true), blank=True, null=True)
}}}

and in the admin.py i have:

{{{
class BarInline(admin.StackedInline):
model = Bar

@admin.register(Foo)
class FooAdmin(admin.ModelAdmin):
inlines = [BarInline]
}}}

Now the issue is on the save form in admin, if i try to create foo
instance without providing any bar data in barinline form, i get error
that bar's required field is required and if i make all fields optional,
it creates the bar instance anyway without any data. I have played with
min_num and max_num but in vain.

--

Comment (by tejinderss):

This bug seems to be valid only when the postgres arrayfield is used in
the inline model

--
Ticket URL: <https://code.djangoproject.com/ticket/28950#comment:4>

Django

unread,
Dec 26, 2017, 12:17:46 PM12/26/17
to django-...@googlegroups.com
#28950: ArrayField.has_changed() returns True for unchanged fields
----------------------------------+------------------------------------
Reporter: tejinderss | Owner: nobody
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

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

* component: Uncategorized => contrib.postgres
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

The problem is `ArrayField.has_changed()` returning `True` even though the
field wasn't modified.

--
Ticket URL: <https://code.djangoproject.com/ticket/28950#comment:5>

Django

unread,
Jan 2, 2018, 11:53:24 AM1/2/18
to django-...@googlegroups.com
#28950: ArrayField.has_changed() returns True for unchanged fields
-------------------------------------+-------------------------------------
Reporter: tejinderss | Owner: vinay
| karanam
Type: Bug | Status: assigned

Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by vinay karanam):

* owner: nobody => vinay karanam
* status: new => assigned


Comment:

I've raised a [https://github.com/django/django/pull/9520 PR] implementing
necessary changes.

--
Ticket URL: <https://code.djangoproject.com/ticket/28950#comment:6>

Django

unread,
Apr 7, 2018, 6:25:16 PM4/7/18
to django-...@googlegroups.com
#28950: ArrayField.has_changed() returns True for unchanged fields
-------------------------------------+-------------------------------------
Reporter: tejinderss | Owner: vinay
| karanam
Type: Bug | Status: closed
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"6a1957bb9887f8e0bb69d3d2b180a1414d38c1fc" 6a1957b]:
{{{
#!CommitTicketReference repository=""
revision="6a1957bb9887f8e0bb69d3d2b180a1414d38c1fc"
Fixed #28950 -- Fixed ArrayField.has_changed() for empty values.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28950#comment:7>

Reply all
Reply to author
Forward
0 new messages