Good Django libraries to read to really understand class-based views?

73 views
Skip to first unread message

Robert F.

unread,
Jan 11, 2021, 10:14:33 AM1/11/21
to Django users
Are there any Django libraries that make extensive use of class-based views that I might study if I want to gain an in-depth understanding of how to use them? The Django documentation is OK at explaining what they are and how they work but most of the examples are very trivial in nature. I'd like to become a "power user" and for that I need lots of code to study. I've looked at the Classy Class-Based Views examples but they seem too "meta" to me to shed any real light on how to use them in practice. Thanks.

Arisophy

unread,
Jan 11, 2021, 10:13:56 PM1/11/21
to django...@googlegroups.com
Hello Robert.

Did you read class based views code?
Original django class-based view code is below.



I made an extension class for FormView and ListView. 


I hope it helps you understand how to extend the call-based view .

best regards.

Arisophy

2021年1月12日(火) 0:15 Robert F. <robert....@gmail.com>:
Are there any Django libraries that make extensive use of class-based views that I might study if I want to gain an in-depth understanding of how to use them? The Django documentation is OK at explaining what they are and how they work but most of the examples are very trivial in nature. I'd like to become a "power user" and for that I need lots of code to study. I've looked at the Classy Class-Based Views examples but they seem too "meta" to me to shed any real light on how to use them in practice. Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/eda0feed-fb61-4882-bbc3-14531b13526fn%40googlegroups.com.

Carsten Fuchs

unread,
Jan 12, 2021, 3:50:00 AM1/12/21
to django...@googlegroups.com
Dear Robert,

I recommend you consider https://spookylukey.github.io/django-views-the-right-way/

Best regards,
Carsten


Am 11.01.21 um 16:14 schrieb Robert F.:
> Are there any Django libraries that make extensive use of class-based views that I might study if I want to gain an in-depth understanding of how to use them? The Django documentation is OK at explaining what they are and how they work but most of the examples are very trivial in nature. I'd like to become a "power user" and for that I need lots of code to study. I've looked at the Classy Class-Based Views <https://ccbv.co.uk/> examples but they seem too "meta" to me to shed any real light on how to use them in practice. Thanks.

Benjamin Schollnick

unread,
Jan 12, 2021, 7:41:09 AM1/12/21
to django...@googlegroups.com
I second this, I’m going through this right now, and it’s very useful information regarding Class Based views vs Function Based views…

It’s making me consider rewriting Quickbbs/Gallery again, with a less kludgy approach.

- Benjamin
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c3105eb8-7adf-8e95-e3d6-8908525eb3cb%40cafu.de.

David Nugent

unread,
Jan 12, 2021, 10:21:33 AM1/12/21
to django...@googlegroups.com, Robert F.
Robert,

I think the ultimate resource you can use on this beyond the documentation is the django source code itself.

It may look confusing at first, but if you check out the class hierarchy from the starting points in the docs, how classes are related and mix-ins are used, you gain a lot of insight you don't and can't get from the docs.  With that understanding you are able to author with your own CBVs derived from the bits provided by Django to create a great deal of customisation for you applications where the stock ones may not fit.

There is no better teacher than trying things yourself, working out what went wrong when it does not work.

But I'll provide a nutshell version:

Essentially a CBV is a class that provides functionality around dispatching a web request. At the core is the 
dispatch() method, which passes the request onto specific method handlers.  Anything else beyond that supports more specific use cases that usually simplifies handling the request - i.e. templates - and each of those provides its own set of patterns.

HTH,
/d


On 12 January 2021 at 02:15:11, Robert F. (robert....@gmail.com) wrote:

Are there any Django libraries that make extensive use of class-based views that I might study if I want to gain an in-depth understanding of how to use them? The Django documentation is OK at explaining what they are and how they work but most of the examples are very trivial in nature. I'd like to become a "power user" and for that I need lots of code to study. I've looked at the Classy Class-Based Views examples but they seem too "meta" to me to shed any real light on how to use them in practice. Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Robert F.

unread,
Jan 12, 2021, 4:06:48 PM1/12/21
to Django users
Thank you to everyone who took time to answer my question!  I will check out the resources you mentioned.
Reply all
Reply to author
Forward
0 new messages