Skip to content

Implement LimitedQuerySet class #9

@onyb

Description

@onyb

The result returned by some QuerySet methods do not allow chaining with other methods due to their form. For example, the result of a value_list will not allow operations like order_by.

Any QuerySet method which returns a result where the items are not Model instances qualify to return instances of type LimitedQuerySet.

Example use case:

>>> Foo.objects.filter(...).values_list('pk', 'name', 'idx')
[(123, 'A', 0,), (124, 'B', 1,), ...]  # LimitedQuerySet

>>> Foo.objects.filter(...).values_list('pk', 'name', 'idx').map(lambda c: hash(c))
[-8396369143964016954, 3966759431255512253, ...]  # LimitedQuerySet

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions