我是如果使用带有或条件的 if 语句,但这首先显示错误我没有和或条件错误
print(farm_acerage)
print(batch_acerage)
print(current_acerage)
if farm_acerage in (None, 0):
return Response({"error": True, "message": "Add farm first"},
status = status.HTTP_200_OK)
if farm_acerage is not None and batch_acerage in (None, 0):
if current_acerage > farm_acerage:
return Response({"error": True, "message": "Ckkannot add batch more than farm capacity"},
status = status.HTTP_200_OK)
if farm_acerage is not None and batch_acerage is not None:
batch_acerage = float(batch_acerage) + float(current_acerage)
if batch_acerage > farm_acerage:
return Response({"error": True, "message": "Cannot add batch more than farm capacity"},
status=status.HTTP_200_OK)
错误是
2.0
None
1.0
'>' not supported between instances of 'str' and 'float'