About This Talk
What is a Generic Class-Based View (CBV)?
I’ll give a general explanation of what a CBV is.
CBV vs Function-Based View
Comparisons with function-based views, showing a few sample conversions between some simple function-based views and CBVs.
Discussion about reasons to use use CBVs, and times when maybe they aren’t the best tool.
URL Routing and
Talk about how your
urls.py handles using a CBV instead of a function. Also go into detail about how CBVs’
as_view method works.
Discuss how dispatch works. This part is simple, until you start writing your own generic views that you’ll subclass later.
Some Common CBVs
Talk about a few common CBVs and the methods/attributes they add to the mix.
You can actually create class mixins that you can combine with the built-in CBVs to do some great things. I’ll talk about how to create a simple mixin, and reasons you might want to do it.
Decorating a CBV
There are some interesting things to keep in mind when decorating classes, especially when decorating classes you are going to subclass.
Creating your own CBV
Talk about a few reasons you might want to create your own CBV, and some seemingly good, but actually bad reasons.
Example of a Bad CBV
I thought it was a good idea at the time to write a CBV that handled multiple forms with a variety of different arguments. When I wrote it, it worked out great! But when it came time to maintaining it, and passing the project on to other developers, it broke apart.
What Do You Get Out of this Talk?
Hopefully, this talk will have you walking away with:
- An understanding of how generic views work
- Pros/cons to using generic views
- An example of a view you should probably never create…
I’m a full stack developer at University of Texas at Austin. I self-describe as a dog person, but somehow have 3-4 cats (one comes and goes) and no dogs at the moment. Interestingly, two of my cats were born the very first day I started as a developer so they’ve grown up with my career. In my spare time I like to learn about tech that I don’t use at work, play video games like Elder Scrolls, and spend time with my partner and friends.