#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 <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.39f23aaf87a41b0978a58b25b9e85eba%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to