filmov
tv
how to retrieve objects in Django using filter() & exclude() methods part 10 | Django in deep

Показать описание
In Django, you can retrieve objects from the database using the #filter () and #exclude () methods provided by the QuerySet API. Here's an explanation of how these methods work:
1 filter(**kwargs):
The filter() method allows you to retrieve objects that match specific conditions or criteria. It accepts keyword arguments (**kwargs) to define the filtering parameters. The method returns a new #queryset containing objects that satisfy the given lookup parameters.
2 exclude(**kwargs):
The exclude() method, as the name suggests, allows you to exclude objects that match certain conditions. It works similarly to filter() but returns a new QuerySet containing objects that do not satisfy the given lookup parameters
#key moments
00:00 intro
01:23 views, urls, and template that we will be using
08:26 how to use all() to retrieve all objects from the database
14:08 how to use filter() method to retrieve specific objects
17:59 how to use exclude() method to exclude specific objects
20:28 how to chain filters
1 filter(**kwargs):
The filter() method allows you to retrieve objects that match specific conditions or criteria. It accepts keyword arguments (**kwargs) to define the filtering parameters. The method returns a new #queryset containing objects that satisfy the given lookup parameters.
2 exclude(**kwargs):
The exclude() method, as the name suggests, allows you to exclude objects that match certain conditions. It works similarly to filter() but returns a new QuerySet containing objects that do not satisfy the given lookup parameters
#key moments
00:00 intro
01:23 views, urls, and template that we will be using
08:26 how to use all() to retrieve all objects from the database
14:08 how to use filter() method to retrieve specific objects
17:59 how to use exclude() method to exclude specific objects
20:28 how to chain filters