python - Get number of results from Django's raw() query function -
I am using a raw query and I'm having trouble finding out how much results it gives. Is there any way?
Edit
. Count () does not work. Returns the returns: There is no attribute 'counts' in the 'RawQuerySet' object
Looks like you're talking about raw ()
queryet method It gives a query like any other, of course, you can call .count ()
, as if you can call on another ORM query.
Edit shows what happens when you do not check as you notice, .raw ()
returns a RawQuerySet In which there is no counting method - nor does it support len ()
The only way to get the length is to repeat through the query and count them:
sum (As result result 1)
Comments
Post a Comment