Skip to main content

truelist-django

Free tier Django integration for the Truelist email validation API. Provides a Django model field validator, a DRF serializer field, and caching via Django's cache framework.

Built on top of the truelist Python SDK.

Start free — 100 validations + 10 enhanced credits, no credit card required. Get your API key →

Installation

pip install truelist-django

With DRF support:

pip install "truelist-django[drf]"

Quick Start

Add your API key to Django settings:

# settings.py
TRUELIST_API_KEY = "your-api-key"

Django Validator

Use TruelistEmailValidator on any model field:

from django.db import models
from truelist_django.validators import TruelistEmailValidator

class User(models.Model):
    email = models.EmailField(
        validators=[TruelistEmailValidator()]
    )

With options:

class User(models.Model):
    email = models.EmailField(
        validators=[TruelistEmailValidator(
            allow_risky=True,      # Accept accept-all domains (default: True)
            fail_silently=True,    # Don't block on API errors (default: True)
        )]
    )

The validator is @deconstructible, so it works in Django migrations.

DRF Serializer Field

Use TruelistEmailField in any DRF serializer:

from rest_framework import serializers
from truelist_django.fields import TruelistEmailField

class SignupSerializer(serializers.Serializer):
    email = TruelistEmailField()

With options:

class SignupSerializer(serializers.Serializer):
    email = TruelistEmailField(
        allow_risky=False,
        fail_silently=True,
    )

Settings Reference

All settings are optional except TRUELIST_API_KEY.

Setting Default Description
TRUELIST_API_KEY "" Your Truelist API key (required)
TRUELIST_BASE_URL "https://api.truelist.io" API base URL
TRUELIST_TIMEOUT 10 Request timeout in seconds
TRUELIST_ALLOW_RISKY True Accept emails with "risky" state by default
TRUELIST_CACHE_ENABLED False Enable caching of validation results
TRUELIST_CACHE_TTL 3600 Cache duration in seconds
TRUELIST_CACHE_ALIAS "default" Which Django cache backend to use

Caching

Enable caching to reduce API calls for repeated validations:

# settings.py
TRUELIST_CACHE_ENABLED = True
TRUELIST_CACHE_TTL = 3600  # 1 hour
TRUELIST_CACHE_ALIAS = "default"

When caching is enabled, validation results are stored in Django's cache framework. Results with unknown state are never cached, so they are always re-validated.

You can also use the cached client directly:

from truelist_django.cache import CachedTruelistClient

client = CachedTruelistClient()
result = client.validate("user@example.com")
print(result.state)  # "ok", "email_invalid", "risky", or "unknown"

Validation States

The Truelist API returns one of four states:

State Description Default Behavior
ok Email is deliverable Passes validation
email_invalid Email is not deliverable Fails validation
risky Email may be deliverable (accept-all domain) Passes when allow_risky=True (default)
unknown Could not determine deliverability Passes when fail_silently=True (default)

Authentication errors (401) always raise, regardless of fail_silently.

Error Handling

By default (fail_silently=True), API errors and network issues are logged and the email passes validation. This prevents your forms from breaking when the Truelist API is unavailable.

Set fail_silently=False to reject emails when the API cannot be reached.

Authentication errors (invalid API key) always raise immediately, regardless of fail_silently.

Testing

pip install -e ".[dev]"
python -m pytest tests/ -v

Compatibility

  • Python 3.9+
  • Django 4.2, 5.0, 5.1
  • DRF 3.14+ (optional)

Getting Started

Sign up for a free Truelist account to get your API key. The free plan includes 100 validations and 10 enhanced credits — no credit card required.

License

MIT

Metadata

Release files for truelist-django 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for truelist-django 0.1.0
File Size Uploaded Provenance
truelist_django-0.1.0.tar.gz 10.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for truelist-django 0.1.0
File Interpreter ABI Platform
truelist_django-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.5 kB

Release files / truelist_django-0.1.0.tar.gz

Download URL truelist_django-0.1.0.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9db760ef1dcbe160a74806d28372dcad2ea2f919852e5af08daa6b2b050b3813
BLAKE2b-256 checksum
How to use checksums
35581c71809530e5aec97073fdebed3e22f8e70ecc98df7d82388e68e95c6871
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / truelist_django-0.1.0-py3-none-any.whl

Download URL truelist_django-0.1.0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6c7b15ee42020bd62a57c200a4a74d2ca0fcb2d85ea2a569de0eb1f7b7f6757
BLAKE2b-256 checksum
How to use checksums
56df0eb5cee28b177ebf57d33af3a852162a2f7881d3d6173749d75d913d2b55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for truelist-django 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page