how to limit django admin inline formsets

和自甴很熟 提交于 2020-04-29 10:19:18

问题


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.


回答1:


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?



来源:https://stackoverflow.com/questions/5481015/how-to-limit-django-admin-inline-formsets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!