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.
* Attachment "Capture.PNG" added.
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>
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>
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>
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>
* 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>
* 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>
* 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>