Skip to content

Management Commands

download_geoip

Downloads / refreshes the GeoIP country database used by country blocking.

python manage.py download_geoip

It writes to --output, else GEOIP_PATH, else <BASE_DIR>/geoip/GeoLite2-Country.mmdb; a directory is resolved to GeoLite2-Country.mmdb inside it. The download is staged beside the target and moved into place only after the checksum matches and geoip2 can open it, so a failed run never replaces a working database.

Flag Setting Effect
--release <tag> NAI_SECURITY_GEOIP_RELEASE Release tag to fetch. Defaults to the tag pinned in the command
--sha256 <digest> NAI_SECURITY_GEOIP_SHA256 Expected SHA-256 of the downloaded file
--allow-unverified โ€” Install without a checksum, trusting the mirror
--output <path> GEOIP_PATH Where to write the .mmdb

The pinned default release ships with its digest. Any other release with no checksum fails: the command raises CommandError, installs nothing, and prints the digest it saw so you can re-run with --sha256 <digest> once you trust those bytes โ€” or with --allow-unverified. Country attribution drives country blocking and allowlist mode, so an unverified mirror is a real exposure.

python manage.py download_geoip --release 2026.10.01 --sha256 <digest>

Every failure exits non-zero โ€” download error, checksum mismatch, unreadable file. Versions up to 1.18.0 printed a warning and exited 0 for an unverified download, so a cron job that only checks the exit status will start reporting failures it used to swallow.

Ensure GEOIP_PATH points at the resulting .mmdb file (or the path your command writes to).

sync_security_lists

Syncs public disposable-email domains and/or bad-bot user agents into your DB.

# everything enabled in SecuritySettings
python manage.py sync_security_lists

# domains only
python manage.py sync_security_lists --domains-only

# bots only
python manage.py sync_security_lists --bots-only

Requires network access (requests). Controlled by SecuritySettings flags:

  • sync_disposable_domains
  • sync_bad_bots