Intro to Class-Based Views in Django

  Рет қаралды 35,037

Pretty Printed

Pretty Printed

Күн бұрын

Пікірлер: 34
@prettyprinted
@prettyprinted 4 жыл бұрын
Join my free course on working with the database and models in Django: prettyprinted.com/djangodatabase
@SisiraSomaratne
@SisiraSomaratne 4 жыл бұрын
I struggled a lot to learn this for days. Thank You! It's very clear now.
@ajaysharma1560
@ajaysharma1560 4 жыл бұрын
Please keep posting .. Your work is really very helpful.
@litebook1951
@litebook1951 3 жыл бұрын
Where from did you learn class based view?
@liorbm1
@liorbm1 4 жыл бұрын
Is this in Django REST Framework ? Or in Django ?
@mujeebishaque
@mujeebishaque 5 жыл бұрын
Got your email recently about the new flask uploads. I haven't checked it out as I am more into Django. This video is pretty easy to follow and understand. Thanks Anthony.
@jonathanhirschbaum6754
@jonathanhirschbaum6754 5 жыл бұрын
Class based views are most probably awesome, but in this particular case it just doubles the amount of lines. I cant find any added value except turning it slowly into Java. I dont know a thing about class based views, it's just my first impression. I was sure improvements works other way around - reducing boilerplate instead of literally multiplying it.
@MK-oj8ol
@MK-oj8ol Жыл бұрын
This video misses most of the point of class based views. The author is using the most basic 'view' object, which requires that he repeat most of the logic from his function based view in the class based view, which provides very little benefit. The true 'magic' happens when your new class based view inherits from one of the generic views such as FormView, CreateView, UpdateView, etc. All you have to do is set a few properties within the class and eliminate the boilerplate code that is shown in this example. If you are watching this video you should really try to find another example that illustrates use of the generic views in order to better understand the true power of class based views.
@michaeljohn-kl6pm
@michaeljohn-kl6pm 4 жыл бұрын
in CarView class there are two functions called get and post. Those name are default by django or can i give a different name for those tow classes
@dilipyadav1264
@dilipyadav1264 4 жыл бұрын
What u wnt to do u can.
@classicguy7813
@classicguy7813 5 жыл бұрын
thanks a lot how to get the current Post in home page while commenting. because there are many posts and when I click I want vivre to recognize which posts I am commenting. pk= 2 but I want pk = pk and it gets more posts on listview and confused the comment form
@mayanktripathi4u
@mayanktripathi4u 5 жыл бұрын
Hi Team, I am using CLass based views (ListView) and want to display the list of items but at the same time need to join two tables to get the desired result. Any info where i can overwirte the method or function to use custom based query.? Looking for response... Thanks
@prettyprinted
@prettyprinted 5 жыл бұрын
Maybe this will help you: docs.djangoproject.com/en/2.2/topics/class-based-views/generic-display/#dynamic-filtering
@jonathanhirschbaum6754
@jonathanhirschbaum6754 5 жыл бұрын
Seriously? You just type random video in YT loosely similar to your job and simply ask author to solve your completely unrelated problems? While on it, Im looking for Mexican recipes, preferably beans and chili, can someone paste it here?
@felomleron.ml101
@felomleron.ml101 3 жыл бұрын
@@jonathanhirschbaum6754 do you still need recipes?
@alfredglaygbo6595
@alfredglaygbo6595 Жыл бұрын
I'm finding it difficult to understand the use of class base view
@sushant6295
@sushant6295 5 жыл бұрын
great videos dude.... why did you use pk=2 . can anyone clarify
@prettyprinted
@prettyprinted 5 жыл бұрын
As an example. Since I wasn't taking user input, I needed a way to change the data.
@zhaoyinqin1813
@zhaoyinqin1813 5 жыл бұрын
I saw people using form_class, add_form, and form. What are the differences?
@krystianpominski5162
@krystianpominski5162 5 жыл бұрын
It's just local variable. You can even name it "something" and the only difference is gonna be that how you named it.
@marvinotieno2194
@marvinotieno2194 5 жыл бұрын
How can i pass a primary key of an object to a class based view?
@prettyprinted
@prettyprinted 5 жыл бұрын
You can set up the url to accept IDs like with function based views. Then in the method inside of the class, you add the ID to the parameters after request.
@marvinotieno2194
@marvinotieno2194 5 жыл бұрын
@@prettyprinted oh yes it worked
@zulfiqarabid2755
@zulfiqarabid2755 6 жыл бұрын
I've a REQUEST... can you make a video on more real projects like. a small website where we login as admin and have authority to remove or add other accounts. and someone can easily make an account and start posting etc. like a mini social network? wouldn't be that great?
@prettyprinted
@prettyprinted 5 жыл бұрын
I do want to make more complicated examples that aren't in my courses. Look out for those videos.
@webtutor1002
@webtutor1002 5 жыл бұрын
in class multiple methods is there how i can pass this method in url file in is_view()
@prettyprinted
@prettyprinted 5 жыл бұрын
I'm not sure what you mean.
@webtutor1002
@webtutor1002 5 жыл бұрын
​@@prettyprinted if i created user defined method inside class how i call him in url
@rohitbhanot7809
@rohitbhanot7809 5 жыл бұрын
Though I always like all of ur videos, but in this case, I don't really get when n why would u use class based views
@prettyprinted
@prettyprinted 5 жыл бұрын
It's just a different way of organizing the code. Class based views would be useful if you either plan to have endpoints with the same name but multiple request methods. Or if you want to use the Django generic class methods to save writing repetitive code.
@Shadownrun2
@Shadownrun2 5 жыл бұрын
come on... you could make a def for rendering instead of declaring form, context and calling render for both methods! That is super usefull!! anyways thank you for the video
@prettyprinted
@prettyprinted 5 жыл бұрын
You're welcome! Thanks for watching!
@JG-qj1xb
@JG-qj1xb 5 жыл бұрын
This is a pretty bad way to use the class Model in django.
@mujeebishaque
@mujeebishaque 5 жыл бұрын
please teach a good way then.
Using Django in a Standalone Script
8:45
Pretty Printed
Рет қаралды 18 М.
What are Django class based views & should you use them?
36:19
Dennis Ivy
Рет қаралды 85 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
How Model Queries Work in Django
27:47
Pretty Printed
Рет қаралды 95 М.
Разбор классов Django View | ListView | DetailView | Михаил Омельченко
1:09:01
Михаил Омельченко | Django School
Рет қаралды 16 М.
Django Class Based Views Tutorial
31:34
Matt Freire
Рет қаралды 46 М.
Creating function based views in Django [16 of 24] | Django for Beginners
6:00
Easily Convert Django Function Based Views To Class Based Views
11:58
ViewSets in Django Rest Framework and Types #10
13:26
IamPython
Рет қаралды 12 М.
Django vs Node js in 2025 - Make the Right Choice (Difference Explained)
11:07
Daniel | Tech & Data
Рет қаралды 69 М.
The Basics of Django Models
37:32
Pretty Printed
Рет қаралды 99 М.
CS50W - Lecture 3 - Django
1:39:05
CS50
Рет қаралды 482 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН