如何限制django管理员内联表单集 [英] how to limit django admin inline formsets
本文介绍了如何限制django管理员内联表单集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在django admin中限制内联表单集?
How do you limit the inline formset in django admin?
问题:
我有一张桌子与B有1到n的关系。表A至少应有一个表B项,最多有5个表B项。
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.
推荐答案
http://docs.djangoproject.com/en/dev/ref/ contrib / admin /#inlinemodeladmin-options
在中指定
定义以限制数量。 max_num
内联
Specify max_num
in your Inline
definition to limit the number.
extra
指定要显示的空白内联数量。
extra
specifies how many blank inlines to show.
是否需要1个内联?如您要在表B中未填充至少1行时触发验证错误?
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?
这篇关于如何限制django管理员内联表单集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文