我试图通过不将许多对象的ID保存到多字段并尝试到达except块来引发错误,但它仍会引发值错误。除了块不被调用。
try:
def save_model(self, request, obj, form, change):
stop = False
print("test2")
if "_stop" in request.POST:
stop = True
obj.save()
state_id = request.POST.getlist('state')
get_homescommunity_data(request, state_id, stop)
except ValueError:
print("test1")
redirect("/admin/newhomedata/communitypagesurl/")