50👍
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?
0👍
The enabling / disabling of the add button in an inline is managed through the _has_add_permission
method
you could add to your inline class:
def _has_add_permission(self, request, obj=None):
# add/remove possibility to add a line to an inline
if obj.table_b_items.count() < 5:
return True
else:
return False
- [Django]-Django 2, python 3.4 cannot decode urlsafe_base64_decode(uidb64)
- [Django]-How to access Django's field.choices?
- [Django]-Aggregate (and other annotated) fields in Django Rest Framework serializers
Source:stackexchange.com