Keep history of all emails sent by Django Anymail
anymail-history implements database storage for Django Anymail.
$ pip install "django-anymail-history"
INSTALLED_APPS = [
# ...
"anymail",
"anymail_history",
# ...
]
Then migrate the app to create the database table
manage.py migrate
You can add settings to your project’s settings.py either as a single ANYMAIL
dict, or by breaking out individual settings prefixed with ANYMAIL_. So this settings dict:
ANYMAIL = {
"STORE_HTML": True,
}
…is equivalent to these individual settings:
ANYMAIL_STORE_HTML = True
ANYMAIL_STORE_FAILED_SEND
: (default: False) Store message even if esp didn’t returned a message-id.ANYMAIL_STORE_HTML
: (default: False) Store html alternatives.black
, ruff
)pyupgrade
)mypy
)We use pre-commit to run code quality tools.
Install pre-commit however you like (e.g.
pip install pre-commit
with your system python) then set up pre-commit to run every time you
commit with:
> pre-commit install
You can then run all tools:
> pre-commit run --all-files
It includes the following:
poetry
for dependency managementRuff
, black
and pyupgrade
lintingmypy
for type checkingGithub Actions
for builds and CIThere are default config files for the linting and mypy.
The package tests themselves are outside of the main library code, in a package that is itself a
Django app (it contains models
, settings
, and any other artifacts required to run the tests
(e.g. urls
).) Where appropriate, this test app may be runnable as a Django project - so that
developers can spin up the test app and see what admin screens look like, test migrations, etc.
The tests themselves use pytest
as the test runner. If you have installed the poetry
evironment,
you can run them thus:
$ poetry run pytest
or
$ poetry shell
(anymail-history-py3.10) $ pytest
.github/workflows/lint.yml
: defines and ensure coding rules on Github.
.github/workflows/test.yml
: Runs tests on all compatible combinations of Django (3.2+) & Anymail(8.4+), Python (3.8+)in a Github matrix.
.github/workflows/coverage.yml
: Calculates the coverage on an up to date version.