Djaq Management Command

If you include the djaq_ui app in your INSTALLED_APPS, you have the ./ djaq command at your disposal:

./ djaq Book --output "pubdate.year" --where "pubdate.year > 2013" --order_by " -pubdate.year"

Most features are available:

 ./ djaq
usage: djaq [-h] [--output OUTPUT] [--where WHERE] [--order_by ORDER_BY] [--format FORMAT] [--schema] [--dataclass] [--limit LIMIT]
                    [--offset OFFSET] [--distinct] [--sql] [--count] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH]
                    [--traceback] [--no-color] [--force-color] [--skip-checks]

Most options are obvious, but some or not related to queries. --dataclass is use to generate code for a dataclass corresponding to the given Django model:

 ./ djaq Book --dataclass
class BookEntity:
    id: int
    name: str
    pages: int
    price: Decimal
    rating: int
    publisher: int
    alt_publisher: int
    in_print: bool

It’s not very sophisticated but should save some typing.