How do I print to the terminal the query used by a specific line of python code? see below
notifications = user.get_notifications(max_id=max_id, types=types).order_by('-created')[:count]
How do I print to the terminal the query used by a specific line of python code? see below
notifications = user.get_notifications(max_id=max_id, types=types).order_by('-created')[:count]
You can print the query by adding:
.query
after your call.
It'll look like this:
user.get_notifications(max_id=max_id, types=types).order_by('-created')[:count].query
If you're doing this in the py manage.py shell
, don't forget to print()
it out. Otherwise it will show a memory address.