Home > Net >  Django ORM question about methods for the QuerySet Object
Django ORM question about methods for the QuerySet Object

Time:10-22

Can someone explain to me why you can use a method like count() for a QuerySet Object but something like pop() does not work.

CodePudding user response:

The reason is that, unlike a list, a QuerySet is a special type that isn't evaluated unless you perform any computation on its data. Its purpose is to store query results and can be manipulated using query methods such as .filter(), .order_by(), etc. As opposed to a list of objects that consumes RAM space, a QuerySet won't do that much. So, it doesn't support list methods such as remove or pop, etc. that perform manipulation.

  • Related