Opened 6 years ago

Last modified 6 years ago

#28950 closed Bug

Model with OnetoOneFeild inline in admin cannot be created — at Version 4

Reported by: tejinderss Owned by: nobody
Component: contrib.postgres Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by tejinderss)

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.

Change History (5)

by tejinderss, 6 years ago

Attachment: Capture.PNG added

comment:1 by tejinderss, 6 years ago

Description: modified (diff)

comment:2 by tejinderss, 6 years ago

Description: modified (diff)

comment:3 by Tim Graham, 6 years ago

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

comment:4 by tejinderss, 6 years ago

Description: modified (diff)

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

Note: See TracTickets for help on using tickets.
Back to Top