Skip to main content

Pretty-print Django QuerySets.

Project description

Django Tabulate

Django Tabulate is a simple app on top of Python tabulate, but for Django querysets.
It allows us to to Pretty-print Django QuerySets

* **Python**: 2.7, 3.5
* **Django**: 1.8, 1.11
* **tabulate**: 0.8.1

Tested on these, but should still work on all actively supported Python and Django versions.


Install using pip:

.. code-block:: sh

pip install django-tabulate


You can use it as a function:

.. code-block:: python

from myapp.models import MyModel
from django_tabulate import tabulate_qs
print tabulate_qs(MyModel.objects.all())
| id | name |
| 1 | Python |
| 2 | Django |
| 3 | Tabulate |

Or as a QuerySet mixin:

.. code-block:: python
from django.db import models
from django_tabulate import TabulateMixin

class MyModelQuerySet(models.QuerySet, TabulateMixin):

class MyModel(models.Model):
name = models.CharField(max_length=255)

objects = MyModelQuerySet.as_manager()

#then in the shell
from myapp.models import MyModel
print MyModel.objects.all().tabulate()


You can override all default tabulate settings via `TABULATE_DEFAULTS`

.. code-block:: python
'tablefmt': 'psql'

For a complete list of all tabulate options take a look at

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution (8.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page