Opened 4 years ago

Closed 4 years ago

#32058 closed New feature (wontfix)

Add count() to RawQuerySet.

Reported by: jkevingutierrez Owned by: nobody
Component: Database layer (models, ORM) Version: 3.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by jkevingutierrez)

count() doesn't exist in RawQuerySet.

AttributeError: 'RawQuerySet' object has no attribute 'count'

Here is an implementation:
https://stackoverflow.com/a/18179123/4508187

Change History (4)

comment:1 by jkevingutierrez, 4 years ago

Description: modified (diff)

comment:2 by jkevingutierrez, 4 years ago

Description: modified (diff)

comment:3 by Mahanth kumar, 4 years ago

But count() exists in FlatValuesListIterable , Can't we use that ?

I'm new here

Version 0, edited 4 years ago by Mahanth kumar (next)

in reply to:  3 comment:4 by Mariusz Felisiak, 4 years ago

Component: UncategorizedDatabase layer (models, ORM)
Resolution: wontfix
Status: newclosed
Summary: Add count to RawQuerysetAdd count() to RawQuerySet.
Type: UncategorizedNew feature

Thanks for this ticket, however RawQuerySet doesn't implement all methods you can use with QuerySet and is not intended to do this. We cannot mirror QuerySet.count() because there is no annotation/aggregation mechanism in RawQuerySet and wrapping a raw SQL (suggested in stack overflow) can be clunky. You can start a discussion on DevelopersMailingList if you don't agree.


Replying to Mahanth kumar:

But count() exists in Queryset , Can't we use that ?

No, these are different classes.

Note: See TracTickets for help on using tickets.
Back to Top