Django = 2.0
我希望这个应用程序添加到我的项目 - https://github.com/pythonsd/test-driven-django-development/tree/master/myblog
它对我有用,但我不需要评论。 我无法弄清楚如何删除这些评论。在HTML中我知道如何删除它,但我想从模型和视图中删除注释,我希望在我的项目中有干净的代码。
https://github.com/pythonsd/test-driven-django-development/blob/master/myblog/blog/models.py - 我要删除班级Comment(models.Model)
,对吗?我想是的。
https://github.com/pythonsd/test-driven-django-development/blob/master/myblog/blog/views.py - 但是我需要从文件中删除,如果我在blog-app
中没有评论?
非常感谢你。
class EntryDetail(DetailView):
model = Entry
template_name = 'test/blog-detail.html'
def get_success_url(self):
return self.get_object().get_absolute_url()
这是工作。