How to get COUNT query in django

From docs:

count()

Returns an integer representing the number of objects in the database matching the QuerySet.

Thus, you can't.

However, you can make use of django.db.connection.queries in order to see and access the queries that are made by the current process.

>>> from django.db import connection
>>> User.objects.count()
>>> print connection.queries

Note that, this works only when DEBUG=True and you can't access them from another process, you can't share between views.

The best option would be to use the Django debug toolbar.