我正在尝试在另一个模型对象实例中获取此错误:
Manager isn't accessible via topic instance
这是我的模型:
class forum(models.Model):
# Some attributs
class topic(models.Model):
# Some attributs
class post(models.Model):
# Some attributs
def delete(self):
forum = self.topic.forum
super(post, self).delete()
forum.topic_count = topic.objects.filter(forum = forum).count()
这是我的看法:
def test(request, post_id):
post = topic.objects.get(id = int(topic_id))
post.delete()
我得到:
post.delete()
forum.topic_count = topic.objects.filter(forum = forum).count()
Manager isn't accessible via topic instances
topic
确实是实际的模型类,而不是根据他提供的代码的实例。