1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | class ChildModelInlineAdmin(admin.TabularInline):
# Here you can specify a number
# of additional inlines (extra) for add_view.
extra = 3
model = SomeModel
class SomeParentModelAdmin(admin.ModelAdmin):
inlines = (ChildModelInlineAdmin,)
def get_formsets(self, request, obj=None):
for inline in self.inline_instances:
fs = inline.get_formset(request, obj)
if obj:
# Here you can specify a number
# of additional inlines (extra) for change_view.
fs.extra = 0
yield fs
|
More like this
- Generating an InlineModelAdmin Form on the fly by timbroder 8 months, 1 week ago
- Dynamically alter the attributes of a formset by cronosa 2 years, 11 months ago
- Form with Two InlineFormSets by maeck 4 years, 5 months ago
- Complex Formsets by smagala 4 years, 4 months ago
- Creator/updater fields for admin by baumer1122 4 years, 10 months ago
Comments