theatlantic / django-nested-admin

Django admin classes that allow for nested inlines
http://django-nested-admin.readthedocs.org/
Other
690 stars 97 forks source link

Bug: Nested inlines don't work properly with extra=0 #235

Open AlexOteiza opened 1 year ago

AlexOteiza commented 1 year ago

Reproduction steps:

class Middle(models.Model): top = models.ForeignKey(Top) name = models.CharField(max_length=128)

class Bottom(models.Model): middle = models.ForeignKey(Middle) name = models.CharField(max_length=128)

class BottomInline(NestedStackedInline): extra = 0 model = Bottom

class MiddleInline(NestedStackedInline): model = Middle extra = 0 inlines = [BottomInline]

class TopAdmin(NestedModel): model = Top inlines = [MiddleInline]



- Attempt to create a new Top object in django admin.

The `Top` model creation page has the name field and an empty group of Middle group with zero elements(expected)
But when you add a new `Middle` there is no `Bottom` group. (unexpected)
Only after saving one new `Middle` and re-editing the `Top` model again, `Bottom` Group will show (expected).

This does not happen with extra>0 in the BottomInline class

Django version 4.07