0

I try to use class-based view like below

class DetailBookVIew(DetailView):
    model = Book
    template_name = 'book/detail_book.html'

with model Book is a mongodb model, so how can I use that class-based view with mongodb model, because it will cause error like AttributeError: type object 'Book' has no attribute '_default_manager', the _default_manager attribute only available for sql model.

Cuongpt
  • 45
  • 2
  • 7

1 Answers1

0

You should use Django-mongogeneric to use a Document instead of a Model in Generic views.

Peter Sobhi
  • 2,542
  • 2
  • 22
  • 28
  • Is there any ways else like extend/custom the model simply to make things work? – Cuongpt Feb 23 '18 at 03:38
  • @Cuongpt , I don't think so. You will have to write a lot of code and that is kind of reinventing the wheel. Anyway, this library is so simple to use. – Peter Sobhi Feb 23 '18 at 13:30