Intro to Class-Based Views in Django

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024

ความคิดเห็น • 34

  • @prettyprinted
    @prettyprinted  4 ปีที่แล้ว

    Join my free course on working with the database and models in Django: prettyprinted.com/djangodatabase

  • @SisiraSomaratne
    @SisiraSomaratne 4 ปีที่แล้ว +1

    I struggled a lot to learn this for days. Thank You! It's very clear now.

  • @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.

  • @ajaysharma1560
    @ajaysharma1560 4 ปีที่แล้ว

    Please keep posting .. Your work is really very helpful.

  • @jonathanhirschbaum6754
    @jonathanhirschbaum6754 5 ปีที่แล้ว +3

    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.

  • @liorbm1
    @liorbm1 3 ปีที่แล้ว +1

    Is this in Django REST Framework ? Or in Django ?

  • @litebook1951
    @litebook1951 3 ปีที่แล้ว +1

    Where from did you learn class based view?

  • @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

  • @alfredglaygbo6595
    @alfredglaygbo6595 ปีที่แล้ว

    I'm finding it difficult to understand the use of class base view

  • @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

  • @zulfiqarabid2755
    @zulfiqarabid2755 5 ปีที่แล้ว

    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.

  • @MK-oj8ol
    @MK-oj8ol 8 หลายเดือนก่อน +1

    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.

  • @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 ปีที่แล้ว +2

      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?

    • @ericcartman2294
      @ericcartman2294 3 ปีที่แล้ว +1

      @@jonathanhirschbaum6754 do you still need recipes?

  • @sushant6295
    @sushant6295 5 ปีที่แล้ว

    great videos dude....
    why did you use pk=2 .
    can anyone clarify

    • @prettyprinted
      @prettyprinted  5 ปีที่แล้ว +1

      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.

  • @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 ปีที่แล้ว +1

      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.

  • @marvinotieno2194
    @marvinotieno2194 4 ปีที่แล้ว

    How can i pass a primary key of an object to a class based view?

    • @prettyprinted
      @prettyprinted  4 ปีที่แล้ว +1

      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 4 ปีที่แล้ว

      @@prettyprinted oh yes it worked

  • @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

  • @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 ปีที่แล้ว +1

      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.