Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AlexOteiza opened this issue Apr 1, 2023 · 0 comments
Open

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

AlexOteiza opened this issue Apr 1, 2023 · 0 comments

Comments

@AlexOteiza
Copy link

AlexOteiza commented Apr 1, 2023

Reproduction steps:

  • Create 3 nested models with its inline admin
class Top(models.Model):
    name = models.CharField(max_length=128)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant