[英]Using mongodb with class-based view django
我嘗試使用如下所示的基於類的視圖
class DetailBookVIew(DetailView):
model = Book
template_name = 'book/detail_book.html'
帶有模型的Book
是mongodb模型,因此我如何將基於類的視圖與mongodb模型一起使用,因為它將導致諸如AttributeError: type object 'Book' has no attribute '_default_manager'
錯誤AttributeError: type object 'Book' has no attribute '_default_manager'
, _default_manager
屬性僅適用於sql模型。
您應該使用Django-mongogeneric在“ 通用”視圖中使用文檔而不是模型 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.