liveBook · Manning

Django Awl

As explained in Django in Action

Django Awl is a third-party Django library providing reusable model classes, administration helpers, view decorators, context processors, commands, and testing utilities.

Django Awl is a reusable collection of small tools for Django projects. It gathers recurring application code into one package instead of making each project rewrite the same helpers. section 13.2 section 13.2.2

Install Awl with `python -m pip install django-awl`, then add `awl` to `INSTALLED_APPS`. Its toolbox includes:

  • Model classes, including an abstract model with creation and update timestamps, counters, locks, and ranked objects. section 13.2.2
  • Django Admin helpers, including `FancyModelAdmin`, which reduces boilerplate and can expose related-object or template-rendered columns. section 13.2.2 section 13.6
  • View decorators, context processors, commands, template tags and filters, and testing utilities. section 13.2.2 section 13.6

Run a Django-aware one-off script

A normal Python script does not automatically receive Django setup. Awl's `run_script` command accepts a Python file, loads it inside a Django context, and runs it. This provides a quick alternative to writing a custom management command. section 13.2.2

(venv) RiffMates$ python manage.py test
 bands.tests.TestBands.test_musician_view

Awl's replacement test runner supports ordinary Django test selection, such as invoking one named test method. section 8.7.2

(venv) RiffMates$ python manage.py test =music

Prefixing a test argument with `=` lets WRunner search for matching test names and run every match rather than only the first. section 8.7.2

How Django in Action covers it

How deep it goes
Explains installation and selected models, commands, administration, and testing features while stopping short of a complete API tour.
Examples
Uses timestamped, ranked, counter, and lock models; FancyModelAdmin; run_script; and shortcuts for selecting tests.
What it assumes
Assumes a Django project and basic Python command-line use while supplying the extra setup needed for Django-aware scripts.
What you can do after
Apply Awl by installing it, enabling the app, running Django-aware scripts, customizing Admin classes, and selecting tests by name.
How it connects
Connects Django Awl with Django models, Django Admin, ModelAdmin classes, management commands, and test runners.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.