如果父技术不在数据库上,我想跳过添加子技术,以避免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'],
)
这应该起作用:
except (Dmeo.DoesNotExist):
如果没有,这可能会起作用:
except (models.DoesNotExist):
相关问题 更多 >
编程相关推荐