Why there is no consistency in the examples of the documentation
for example the tutorial is a poll application , in the m2m examples is a restaurant example and group/members example , in the class based views there is an example with book author
so there is no a standard model application to build the examples based on that .
<opinion>
While I don’t have direct knowledge of the why behind the docs, I would say that it makes sense to me.
Beyond the tutorial (which is internally consistent), the rest of the documentation consists of reference material - each page of which should stand alone in being a complete reference to the topic on that page. The examples shown should be minimal examples to highlight the features of that API being described.
Personally, I believe it would be more confusing to either have a set of models where you’re adding / removing attributes or fields on each page, showing models with features not described on that page, or (worst of all) making the person refer to a different page with the full model. I happen to like the separate stand-alone examples in reference material.
If you’re looking for a more full-featured exposition, I’d suggest looking at one or more of the books that have been written covering Django from a more-detailed tutorial style.
</opinion>
Currently I am trying to implement some class based views for the first time.
The first one I am currently working on is the DetailView
.
I am wondering:
Why are the examples in the documentation so complicated and (from my point of view) not intuitively applicable in a hands-on way❓
In the docs of the DetailView
they are showing an example using get_context_data()
, which I absolutely don’t understand (even after investigating it using CCBV)
In contrast I watch the first 45 seconds of a YouTube video and I know how to implement a detail view with the respective class-based view…