Open lukedupin opened 8 years ago
+1
Having the same issue.
Did some digging. The saving breaks if there is multilevel nesting and the extra
attribute in NestedStackedInline
is set to 0
. It means that the sub-sub-level forms do not get created. Attached some code to reproduce:
# models.py
from django.db import models
class A(models.Model):
content = models.CharField(max_length=255)
class B(models.Model):
content = models.CharField(max_length=255)
a = models.ForeignKey(A)
class C(models.Model):
content = models.CharField(max_length=255)
b = models.ForeignKey(B)
#admin.py
from django.contrib import admin
from nested_inline.admin import NestedStackedInline, NestedModelAdmin
from someapp.models import A, B, C
class CAdmin(NestedStackedInline):
model = C
extra = 1
class BAdmin(NestedStackedInline):
model = B
inlines = [CAdmin]
extra = 0 # <-- This breaks the formset generation
class AAdmin(NestedModelAdmin):
inlines = [BAdmin]
model = A
admin.site.register(A, AAdmin)
I'll be more than happy to take part in solving this.
Nice find.
I ended up switching my nested plugin over to: django-nested-admin (2.1.8)
It doesn't support Tabular inline which is a shame, but it seems to work reliably otherwise.
When creating a new nested table, after clicking the Add new, at least one field needs to be changed, and "save and continue" must be clicked twice before a save happens.
Can I throw you guys a couple hundred bucks to fix these?