简体   繁体   English

如何使用ID从Google Appengine删除实体

[英]how to delete entity from google appengine using ids

I'm trying to get the post entity using ID but everytime I try to run this code I get an error 'NoneType' object has no attribute 'delete. 我正在尝试使用ID获取帖子实体,但是每次尝试运行此代码时,都会收到错误“ NoneType”对象没有属性“删除”的错误。 I've tried using every method and variation but no luck. 我尝试使用所有方法和变体,但没有运气。

   post_id = self.request.get("post_id")
   q = db.GqlQuery("SELECT * FROM Post WHERE ID='" + post_id + "'").get()
   q.delete()

I've figured it out. 我知道了。

Here is what I did: 这是我所做的:

post = Post.get_by_id(int(post_id))
post.delete()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Google Appengine中从实体列表下钻到实体实例? - How to drill down from entity list to entity instance in Google Appengine? 如何从我们的应用在谷歌appengine中使用的数据存储中删除行? - How to delete rows from the datastore that our app uses in google appengine? 如何通过appengine访问Google Apps API? - How to access Google Apps API from appengine? 如何从Google App Engine数据存储中删除带有Blob键的实体 - how to delete an entity with blobkeys from google app engine datastore 使用Appengine的NDB从实体的id获取密钥 - Getting key from the id of the entity using Appengine's NDB 将pytest与Google AppEngine一起使用 - Using pytest with Google AppEngine appengine:如何检查数据存储中是否存在实体的属性? - appengine: how can I check if a property from an entity exists in the datastore? 如何将Appengine与来自API的Python脚本流数据一起使用,将数据流传输到Google Cloud BigQuery? - How to stream data into Google Cloud BigQuery using Appengine with Python Script-flowing data from API? Google AppEngine实体组大小和最终一致性 - Google AppEngine Entity group sizes and eventual consistency 如何删除与通过appengine中的Key属性连接的实体连接的所有实体 - How to delete all entities connected to a entity connected through Key property in appengine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM