Dango Views Cheatsheets
ccbv.co.uk
ccbv.co.uk
I'm delighted to see this on the front-page of HN. I hope it's standing up to the HN hug!
It's been a real pleasure to have a hand in something that continues to help people after all this time. CCBV was a group project during a hackday in Feb 2012. Having this here makes me realise that we're only a couple of days past the 10th "birthday" of the website's first commit :)
Edit: As others have pointed out, there's a typo in the title. It should be "Django", rather than "Dango".
I don't know if it's within the rules, but I suggest that the link should be changed too, as the main page (https://ccbv.co.uk/) has more information -- the current article link is to a relatively boring index for the classes in Django 4.0.
cf-cache-status: DYNAMIC
Maybe you should double check your caching? Edit: You've fixed it, it's faster now.Reading Luke's articles brought me back to FBVs, now I avoid CBVs whenever I can and feel happier for it.
The CCBV site from the original post seems nice and handy though.
Many people say that CBVs is Django on Rails but Rails doesn't use multiple inheritance or complicated MRO.
It requires too much knowledge on part of the developer and is generally an abstraction for the sake of abstraction.
Simple functions are much clearer!
It was trivially easy to add authentication, caching, multiple response types and other magic without bothering the rest of the dev team.
Thanks to the authors/maintainers!
I think you mean Django.
Maybe it enforces a strict "no J's" paradigm? No JSON, JavaScript, etc.
Alas...
I miss generic function views, but you can almost use CBV like them: in your view fuction, do "return YourCBV.as_view(params)" and you are good to go. Much easier than subclassing.
Of course, with FastAPI, we know that there an even better API for that: DI. It's more composable, easier to follow, to test and with less side effects.
django-ninja (https://github.com/vitalik/django-ninja/) already offers a lot of that for Django, and I hope it will become a huge success. It is however, currently thinking of using classes somewhere to reuse init view code, so I made a proposal to extend the API design around more flexible approacheshttps://github.com/vitalik/django-ninja/issues/15#issuecomme...
I'm against OOP, I use it myself, but you should use it for what it's good at: multiple operations around a central state, crafting an api with __dunder__ methods, and namespacing related data and operations.