如果父技术不在数据库上,我想跳过添加子技术以避免matching query does not exist.,但是如果我使用.first or .exists,即使使用if not ...也不能工作,或者try catch块保持来自Dmeo.objects.get_or_create(的相同错误,我如何解决这个问题?
回溯
analizer | apps.api.models.DoesNotExist: Dmeo matching query does not exist.
analizer | The above exception was the direct cause of the following exception:
analizer |
analizer | Traceback (most recent call last):
analizer | File "updater.py", line 38, in <module>
analizer | subtechnique, created = Dmeo.objects.get_or_create(落差代码
for subtechnique in src_subtechniques:
for data_subtechniques in subtechnique:
technique = Technique.objects.filter(technique_id=data_subtechniques['technique_id'].partition('.')[0]).exists()
subtechnique, created = Dmeo.objects.get_or_create(
subtechnique_id=data_subtechniques['technique_id'],
technique_name=data_subtechniques['technique'],
url=data_subtechniques['url'],
)发布于 2021-06-03 05:12:00
这应该是可行的:
except (Dmeo.DoesNotExist):
如果不是这样,下面的代码可能会起到作用:
except (models.DoesNotExist):
https://stackoverflow.com/questions/66300254
复制相似问题