django-nested-inline icon indicating copy to clipboard operation
django-nested-inline copied to clipboard

When saving a new top level of a nested table - Changing a field and saving twice is required.

Open lukedupin opened this issue 10 years ago • 4 comments
trafficstars

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?

lukedupin avatar Sep 25 '15 16:09 lukedupin

+1

Having the same issue.

herrri avatar Dec 01 '15 13:12 herrri

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.

herrri avatar Dec 01 '15 14:12 herrri

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.

lukedupin avatar Dec 01 '15 21:12 lukedupin