1

我收到以下错误:

"'used_intent' is an invalid keyword argument for this function"

我的模型在这里:

class Intents(models.Model):
    id = models.AutoField(primary_key=True)
    intent = models.CharField(max_length=300)
    description = models.CharField(max_length=300)
    class Meta:
        db_table = u'intents'

class UsedIntents(models.Model):
    id = models.AutoField(primary_key=True)
    report_id = models.IntegerField()
    used_intent = models.IntegerField()
    class Meta:
        db_table = u'used_intents'

以下是相应的代码行:

usedIntentsElement = xmldoc.getElementsByTagName('intent')
for element in usedIntentsElement:
    try:
        intentsEntry = Intents.objects.get(intent=element.childNodes[0].nodeValue)
        intentsEntryId = intentsEntry.id
    except:
        # if intent is unknown add it to the database and get the id of the new entry
        intentsEntry = Intents(intent=element.childNodes[0].nodeValue)
        intentsEntry.save()
        intentsEntryId = intentsEntry.id
    usedIntentsEntry = UsedIntents(report_id=int(reportEntryId), used_intent=int(intentsEntryId))
    usedIntentsEntry.save()

你们中有人知道这个错误的原因是什么吗?

4

0 回答 0