ReferenceProperty关系在Django的Google App Engine中无法正常工作
我正在使用Google应用程序引擎和Django开发应用程序.我正在使用应用引擎补丁.一些模型具有ReferenceProperty字段.
I am working on an application using Google application engine and Django. I am using app engine patch. Some of the models have ReferenceProperty fields.
问题在于,当我删除引用"模型的某些条目时,应按照外键类型的关系删除使用此ReferenceProperty的条目.但是实际上这是没有发生的.该字段保留没有删除的字段,并导致错误消息:
The issue is that when I am deleting some entries of the Referenced model, it should delete the entries where this ReferenceProperty is being used following the foreign key kind of relation. But actually it is not happening. The field remains without the deleted field and which is causing an error message:
ReferenceProperty failed to be resolved
以下是该模型的一个示例:
Following is an example of the model:
class Topic(db.Model):
title = db.StringProperty(required = True)
body = db.TextProperty(required = True)
category = db.ReferenceProperty(Category,required = True)
status = db.StringProperty(default="open")
creator = db.ReferenceProperty(User,required = True)
class Category(db.Model):
name = db.StringProperty(required = True)
creation_date = db.DateTimeProperty(auto_now_add=True)
creator = db.ReferenceProperty(User,required = True)
class Meta:
verbose_name = "Category"
verbose_name_plural = "Categories"
def __unicode__(self):
return '%s' % (self.name)
当我删除某些类别时,相关主题也应删除.但是不会删除主题,并且会导致"ReferenceProperty无法解决错误"消息.
When I am deleting some of the categories, the related topics should also be deleted. But the topics are not deleted and cause the "ReferenceProperty failed to be resolved error" message.
请提出建议.
谢谢.
当您尝试遵循的引用导致不存在的实体时可能会发生这种情况-可能是因为您已经删除了它.由于无论如何都尝试将其删除,因此您应该简单地捕获并忽略此异常.
This happens when the reference you are attempting to follow leads to a nonexistent entity - probably because you've already deleted it. Since you're trying to delete it anyway, you should simply catch and ignore this exception.