Opened 5 years ago
Closed 5 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 )
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 , 5 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 5 years ago
| Description: | modified (diff) |
|---|
comment:4 by , 5 years ago
| Component: | Uncategorized → Database layer (models, ORM) |
|---|---|
| Resolution: | → wontfix |
| Status: | new → closed |
| Summary: | Add count to RawQueryset → Add count() to RawQuerySet. |
| Type: | Uncategorized → New 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.
But count() exists in Queryset , Can't we use that ?
I'm new here