Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to limit django admin inline formsets

Tags:

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.

like image 290
ginad Avatar asked Mar 30 '11 01:03

ginad


1 Answers

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?

like image 116
Yuji 'Tomita' Tomita Avatar answered Nov 10 '22 02:11

Yuji 'Tomita' Tomita