

def get_max_num(self, request, obj=None, **kwargs):
    max_num = 3
    if obj:
        return (max_num - obj.binarytree_set.count())
    return max_num

dataset/ETHPy150Open django/django/tests/admin_inlines/admin.py BinaryTreeAdmin.get_max_num/original