3 ms·
I use the class-based generic views in a couple of projects. My personal opinion is that the official documentation still needs work, because people end up in t
by ubernostrum 13y ago
I use the class-based generic views in a couple of projects. My personal opinion is that the official documentation still needs work, because people end up in the API reference tree looking for the examples and explanations.
And that is not a happy place to end up when you're just starting out with them, since in there you're seeing the whole inheritance/mixin layout structure, which is what leads to the belief that it's too complicated to use.
Which... no, class-based generics are pretty darned easy. Here are the views for my blog app, for example:
https://github.com/ubernostrum/blog/blob/master/blog/views.py https://github.com/ubernostrum/blog/blob/master/blog/views.p...
It'd be nice to cut down the use of super(), but that's about the only issue I have with it. All of the simpler-CBV implementations I've seen make a few too many assumptions for my personal taste, or otherwise cut down on flexibility in favor of simplifying the inheritance diagram, which I don't agree with as a goal in itself.
- tomchristie 13y agoWorth noting that it's an explicit aim of vanilla views to exactly replicate the functionality of Django's GCBVs. For the docs: "If you believe you've found some behaviour in Django's generic class-based views that can't also be trivially achieved in django-vanilla-views, then please open a ticket, and we'll treat it as a bug." You shouldn't be losing any flexibility by using it instead of using Django's existing GCBV implementation.