Skip to main content

check_user_model

Validates the custom user model configuration by checking that REQUIRED_FIELDS is a list or tuple, the USERNAME_FIELD is not included in REQUIRED_FIELDS, and the username field is unique. It also ensures that is_anonymous and is_authenticated are attributes or properties rather than methods to prevent security vulnerabilities.

def check_user_model(
app_configs: list or None = null,
**kwargs: dict = null
) - > list

Validates the configuration of the custom user model to ensure it adheres to Django's authentication requirements. This function checks for common configuration errors such as improper REQUIRED_FIELDS definitions, non-unique username fields, and incorrect property implementations for is_anonymous or is_authenticated.

Parameters

NameTypeDescription
app_configslist or None = nullA list of application configurations to restrict the check scope; if None, the model is retrieved from the global app registry.
**kwargsdict = nullAdditional keyword arguments passed by the Django system check framework.

Returns

TypeDescription
listA list of Django check error, warning, or critical objects identifying configuration issues with the user model.