MongoUtil.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:restful-api 作者: TeamGhostBuster 项目源码 文件源码
def delete_article(user, list_id, article_id):
    # Retrieve the articled and list to be deleted
    try:
        # Check resource
        the_article = Article.objects.get(id=ObjectId(article_id))
        the_list = List.objects.get(Q(id=ObjectId(list_id)) & Q(articles=the_article))
        # Remove the article from the database
        Article.objects(id=the_article.id).delete()
        # Remove the vote as well
        Vote.objects(article=the_article, list=the_list).delete()
    except Exception as e:
        return type(e).__name__

    the_list.reload()

    return the_list
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号