Opened 6 years ago

Last modified 6 years ago

#28950 closed Bug

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

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

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.

Change History (1)

by tejinderss, 6 years ago

Attachment: Capture.PNG added
Note: See TracTickets for help on using tickets.
Back to Top