Django-Filter - Filtering Django Querysets, Class-Based Views and REST Framework Integration

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 108

  • @xzex2609
    @xzex2609 Месяц назад +2

    I can not believe that this video is only 30 minutes , compacts with lots of information . very useful stuffs.

    • @bugbytes3923
      @bugbytes3923  Месяц назад +1

      Thanks a lot! Great to hear that, cheers!

  • @xzex2609
    @xzex2609 Месяц назад +1

    This channel is Django gold mine .

    • @bugbytes3923
      @bugbytes3923  Месяц назад

      @@xzex2609 thanks a lot for that, glad you think so, cheers!!

  • @garzuze
    @garzuze 8 месяцев назад +2

    Straight to the point and very informational. Loved it!

  • @Davidkiania
    @Davidkiania Год назад +5

    I really really love this channel ... I have learned in 15 mins what could have taken me an hour in other videos and your explanations are excellent and concise. Thank you.

    • @bugbytes3923
      @bugbytes3923  Год назад

      Thank you very much, I'm glad you're enjoying the videos!

  • @axelb.2006
    @axelb.2006 11 месяцев назад

    For me, the best Channel with a big C. Thanks

  • @metalhoe
    @metalhoe Год назад +2

    Thank you, this tutorial helped me very much. I was basing my stuff on another django tutorial of filter search but it was outdated, started new with this one and everything works. All the best 😃

  • @seydinaoumarsamabaly1806
    @seydinaoumarsamabaly1806 2 года назад +2

    Always surprising with content of quality. Thank you for all mate.

  • @AliBakhshi-s3r
    @AliBakhshi-s3r Год назад +1

    After 3 days of trying, by this video my problem is solved :D

    • @bugbytes3923
      @bugbytes3923  Год назад

      Awesome, glad to hear the video helped! 😄

  • @lalomores4686
    @lalomores4686 Год назад +1

    Excellent explanation. Thanks!

  • @keinermendoza4631
    @keinermendoza4631 6 месяцев назад +1

    What an excellent explanation.

  •  11 месяцев назад +1

    As always, your videos are super useful

  • @calimhiro
    @calimhiro 9 месяцев назад

    very great explanations, simple and clear! I love your videos!

  • @frankyang6943
    @frankyang6943 2 года назад +1

    Thank you for your example. this is very helpful to me!

    • @bugbytes3923
      @bugbytes3923  2 года назад

      You are welcome! I’m glad it was useful!

  • @johnchiverton9375
    @johnchiverton9375 Год назад +1

    Great video. Really clearly explained how and why. Looking forward to watching more of your channel.

  • @laszlo.laszlo
    @laszlo.laszlo 2 года назад +4

    Very elegant solutions. Thank you!

  • @samwang8500
    @samwang8500 2 года назад +1

    I appreciate your so clear and awesome tutorial!

    • @bugbytes3923
      @bugbytes3923  2 года назад +1

      Thank you Sam. Appreciate the comment!

  • @sa_codes
    @sa_codes 2 года назад +1

    I needed this video so much! Thanks so much for making all of your videos!

    • @bugbytes3923
      @bugbytes3923  2 года назад +1

      Thanks Ben - glad it was useful!

    • @sa_codes
      @sa_codes 2 года назад

      @@bugbytes3923 No problem. If you ever need a video or blog idea, I've been trying to find a good way to use HTMX to display messages from the Django Message system as they are created, but haven't found a clean way to do it yet. Seems like the sort of thing I normally learn from your videos haha!

  • @prajjwaldangal2022
    @prajjwaldangal2022 6 месяцев назад +1

    really clear explanation

  • @arunima2916
    @arunima2916 2 года назад +3

    covering all the related features nicely with ease, great job, expecting something for the full text search also, thank u!!!

    • @bugbytes3923
      @bugbytes3923  2 года назад

      Thank you! I'll have a look into that.

  • @ravikiranp7532
    @ravikiranp7532 Год назад +2

    Damn! This is a gold mine!

  • @Developer_python_
    @Developer_python_ 7 месяцев назад +1

    You're cool!!!! I just have thought about rest and you start to talk about it))))

    • @bugbytes3923
      @bugbytes3923  7 месяцев назад

      Thanks a lot, appreciate it!

  • @repotranstech
    @repotranstech 2 года назад +1

    Thanks for this amazing tutorial 👍.

  • @محمدحسناسماعیلی-خ2غ

    It was so helpful and useful and also taught simply👏
    Thanks a lot 🙏😊

    • @bugbytes3923
      @bugbytes3923  Год назад

      Thank you very much, I’m glad it was useful! 👍

  • @MrThestormguy
    @MrThestormguy 11 месяцев назад +1

    You are such a boss.

  • @РамисСабирзянов-ъ4г
    @РамисСабирзянов-ъ4г Месяц назад +1

    Thanks a lot!

  • @markomwandasi1447
    @markomwandasi1447 5 месяцев назад +1

    This is good stuff, Thanks

  • @RafaelHenriqueDalegraveZottess
    @RafaelHenriqueDalegraveZottess 7 месяцев назад

    Nice video man, thank you!

    • @bugbytes3923
      @bugbytes3923  7 месяцев назад +1

      Thanks a lot, appreciate it!

  • @odoolens1190
    @odoolens1190 2 года назад +1

    Thanks for this!

  • @developer-pf2fl
    @developer-pf2fl Год назад +1

    it's so helpful . Thank You so Much (Subscribed)

  • @lotharhansen4170
    @lotharhansen4170 Год назад +1

    Thank you!

    • @bugbytes3923
      @bugbytes3923  Год назад

      you're welcome - thank you for watching! :)

  • @AmoahDevLabs
    @AmoahDevLabs 2 года назад +1

    Wonderful. This is really incredible. Keep it up man. Expecting more from you on Django-Unicorn

  • @eugene_mountainland
    @eugene_mountainland Год назад +1

    great stuff, thank you)

    • @bugbytes3923
      @bugbytes3923  Год назад +1

      You're welcome! Thanks for watching.

  • @bmhcode
    @bmhcode Месяц назад

    Thanks very match it was usfule for me

    • @bugbytes3923
      @bugbytes3923  Месяц назад

      @@bmhcode You’re welcome - thanks for watching!

  • @cyonii8683
    @cyonii8683 Год назад +1

    Great tutor

  • @torbjornsvard5771
    @torbjornsvard5771 2 года назад +2

    Great content!. Thanks for all your high Q vids. Is it possible to search for, let's say, multiple genres?

    • @bugbytes3923
      @bugbytes3923  2 года назад

      Thanks a lot, appreciated! Yes it is - I've just recorded a video that will show how to filter on multiple values. Will release this in the next few days after editing ;)

  • @maathias9
    @maathias9 7 месяцев назад

    Grate video! Let's say you want a COUNT value in the bottom of the table (or other cases you might want SUM for other purposes). Is that possible while using django-filters or is there another way to implement that with the features that comes with django-filters? I've been reading through the docs but can't seem to find a way while using django-filters. Thanks for a great channel :)

    • @maathias9
      @maathias9 7 месяцев назад

      Found solution (example) If anyone else needed:
      In views .py -
      book_filter = BookFilter(request.GET, queryset=Book.objects.all())
      books = book_filter.qs
      # Count of the books
      book_count = books.count()
      -- Include book_count in the context, then in your template include {{book_count}} where needed (maybe create a new from your table)

  • @avindafbrz17
    @avindafbrz17 Год назад

    thank you it was so cool and helpful. but i want to ask, i was use django admin for add the product, but the product didnt show up on the website, how to fix it?

  • @ilyosbekkarshiboyev7134
    @ilyosbekkarshiboyev7134 Год назад +1

    Thank you

    • @bugbytes3923
      @bugbytes3923  Год назад

      You're welcome, thanks for watching!

  • @svink312
    @svink312 Год назад

    How to style the dropdown filter to bootstraps class (or any class) e.g. model-form. Some use Crispy Forms but it would be good to have a way to add a html class. For forms it's straight forward but for the filter generated fields+buttons I haven't manage to do it. Any tips/advice? Great video thanks for posting keep it up.

  • @AshokSharma-hk1jc
    @AshokSharma-hk1jc 6 месяцев назад

    Hi, One confusion that when we should specify a field in Meta class and when we can skip.

  • @michaelwalker5950
    @michaelwalker5950 Год назад

    Well presented and easy to understand. I've noticed all the videos on using Django-Filter uses objects.all() to display all database records on the page on render. What if there are 1000s of records that you don't want all rendered, but only the subset displayed after filtering?

    • @bugbytes3923
      @bugbytes3923  Год назад

      Thank you Michael.
      To display a subset, you can use Django Pagination utilities to page the queryset that's returned after the filtering. Could fire up a quick video on this topic, if you'd like.

    • @michaelwalker5950
      @michaelwalker5950 Год назад

      @@bugbytes3923 Thank you for the quick response. I actually figured it out about an hour after asking. I'm using Django-Filters and checking the dictionary if any filters are populated. If yes, display the filtered rows. If no, display nothing. So far seems to be working

  • @AshokSharma-hk1jc
    @AshokSharma-hk1jc 6 месяцев назад

    Hi, one confusion is that when we should specify fields in the meta class and when we can skip still confused.

  • @h3ckphy246
    @h3ckphy246 2 года назад +5

    I would put your video on the docs instead of official documentation. Thank you.

  • @maathias9
    @maathias9 5 месяцев назад

    When you initially load the page, all the books gets displayed in the template. But how would you manage to have the table empty when you load the page? And only fetch the books when you filter? And if the "name" filter is empty and you click search, it then would search the entire db and fetch all the books? Thanks for your work and channel 🙏🏻

    • @bugbytes3923
      @bugbytes3923  5 месяцев назад

      Thanks for the comment! Will try and answer.
      For an initially empty table, you can load no books initally with: Book.objects.none() as the queryset.
      When you apply the filter, you can pass the params to the Book.objects.filter() function.
      You can prevent submitting the form with an empty name filter by adding a minimum length to the field. developer.mozilla.org/en-US/docs/Web/HTML/Attributes/minlength
      Note: a full-table scan over all books will occur no matter what you search for (empty string, or a certain text) unless you have an index on the Book's "name" field. Adding an index would allow much more efficient filtering over a large table.

    • @maathias9
      @maathias9 5 месяцев назад

      @@bugbytes3923 Thank you for your answer. Understood how to tweak my current code a little bit. (wasn't too hard after some clarification) Again, thank you for your work💪🏼

  • @antoinebuldo6356
    @antoinebuldo6356 8 месяцев назад

    For me...a Big newbee its going to fast...can you help me to implement this in my crm that i created to follow my clients?

  • @TomislavMiletic
    @TomislavMiletic Год назад

    Thank you!
    Can you please explain why adding a content field inside of Meta class doesn't work, but adding it above does?
    This:
    import django_filters
    from .models import UserQuestionForLesson
    class QuestionsFilter(django_filters.FilterSet):
    content = django_filters.CharFilter(lookup_expr='icontains')
    class Meta:
    model = UserQuestionForLesson
    fields = [
    'is_answered',
    ]
    It is just an ordinary CharField where user types in a question for a lesson.

    • @bugbytes3923
      @bugbytes3923  Год назад

      Hi Tomislav. The content field you've defined should also work if added to the "fields" list in the Meta class (as longs as it exists as a field on your model). Does that not work?
      One caveat: for a CharFilter, I believe the default lookup is "exact", so there would have to be an exact match between the submitted content, and what's stored in the database for the "content" field

    • @TomislavMiletic
      @TomislavMiletic Год назад

      @@bugbytes3923 that was fast, thank you. Okay so adding a content field into Meta class doesn't work. Yes, there is a "content" charfield in the Question module, and it works if being added above the Meta class, and i used icontains, it is working. Just wanted to ask because i followed the tutorial and didn't understand why it is not working.

    • @bugbytes3923
      @bugbytes3923  Год назад

      @@TomislavMiletic I think because the default lookup is “exact”, that may be why it doesn’t work when it’s only added to Meta.fields? It works above because you override the default and use “icontains” - maybe this is the issue?

    • @TomislavMiletic
      @TomislavMiletic Год назад

      @@bugbytes3923 i will try that but that won't work for me because i don't want users to have to type the whole thing 😕
      Thank you very much!

    • @bugbytes3923
      @bugbytes3923  Год назад

      @@TomislavMiletic If you want to keep the field in Meta, you can use the second of the two approaches (classes) in the code block at this link:
      django-filter.readthedocs.io/en/stable/ref/filterset.html#declaring-filterable-fields
      You can specify not only the field, but also the lookup, directly in the Meta class. Just use a dictionary, rather than a list, with dictionary values being the lookup for that field.

  • @fikkaaps
    @fikkaaps Год назад

    hey can u help me to remove the form label? thanks😊

  • @sharifahmed1925
    @sharifahmed1925 8 месяцев назад

    is there a repo for this code?

  • @billcooper8625
    @billcooper8625 8 месяцев назад

    Would this work with fk? For instance, say you have a class table,student table, & student grades table in the db. In the view, you display students in a table but then with Django-filter could you apply filtering back to the grades for each student to filter the table in the view based on students with certain grades? For instance, show me student in class A and B with Grades of b or higher….

  • @janisrozenbergs4226
    @janisrozenbergs4226 11 месяцев назад

    Great video But I am having an issue that I get a 404 every time I enter a search any suggestions for this? can share my repository if necessary :)

    • @bugbytes3923
      @bugbytes3923  11 месяцев назад

      Feel free to share, sure! I'll have a look.

  • @evgeniigoncharov9507
    @evgeniigoncharov9507 Год назад +1

    top

  • @amine63404
    @amine63404 8 месяцев назад

    Within your list, you are missing "Brave New World"

  • @zackmcnelly
    @zackmcnelly 2 года назад +1

    HTMX Filtering Video?

    • @bugbytes3923
      @bugbytes3923  2 года назад

      I'll do a very quick demo of this in my next video!

  • @devopsliveuz
    @devopsliveuz Год назад +1

    source code pls?

  • @elijahgathanga9831
    @elijahgathanga9831 2 года назад

    Well, Its a good tutorial but i don't think someone who wants to understand the concepts or how it works will get it from here.

    • @bugbytes3923
      @bugbytes3923  2 года назад

      I would suggest to read the django-filter docs and work through an example on there in order to get the concepts better. Sorry this video was not useful for that!