我想从查询集中获取对象
accounts = group.get_external_accounts(include_sub_groups=True)
try:
account: StripeExternalAccount = accounts.get(account_id)
except StripeExternalAccount.DoesNotExist:
return Response(status=status.HTTP_400_BAD_REQUEST)
我试过这个。它工作正常,但我想通过尝试来做到这一点,除了
account: StripeExternalAccount = None
for acc in accounts:
if acc.id == int(account_id):
account = acc
break
if not account:
return Response(status=status.HTTP_400_BAD_REQUEST)