About Sensitive Variables and Error Reporting

In production mode (DEBUG = False), you can hide certain variables from logging in error reports with the decorators @sensitive_variables and @sensitive_post_parameters, as follows:

from django.views.decorators.debug import (
    sensitive_variables, sensitive_post_parameters,
)

@sensitive_post_parameters("email", "password")
@sensitive_variables("user_email", "user_password")
def show_subscription_form(request):
    if request.method == "POST":
        form = SubscriptionForm(data=request.POST)
        if form.is_valid():
            user_email = form.cleaned_data["email"]
            user_password = form.cleaned_data["password"]
            raise Exception()
    ...

Variables in Django settings and request.META containing any of the case-insensitive words "API", "TOKEN", "KEY", "SECRET", "PASS", "SIGNATURE" in their names will be hidden from reports too.

The values of hidden variables will be shown as **********.

Django 4.2 Django 3.2