how to limit django admin inline formsets
23,959
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-options
Specify max_num
in your Inline
definition to limit the number.
extra
specifies how many blank inlines to show.
Is the 1 inline required? As in you want to trigger a validation error if table B isn't filled with at least 1 row?
Related videos on Youtube
Comments
-
ginad almost 2 years
How do you limit the inline formset in django admin?
Problem:
I have a table A with 1 to n relationship with B. Table A should have at least one Table B item and a max of 5 Table B items.
-
Yuji 'Tomita' Tomita about 13 yearsI'm not aware of a way to disable the add button.
-
Snigdha Batra over 9 yearsThe add button is hidden by default if the total number of forms shown crosses the max_num specified. So if your max_num is 5 , and you want to disable the add button specify extra = 5 Else whenever total forms reaches 5, add button will be hidden