Skip to main content

create_permissions

Creates default permissions for all models in a given application configuration, ensuring that required content types are generated beforehand. This function performs bulk database inserts and may output status messages to the console based on the verbosity level.

def create_permissions(
app_config: AppConfig,
verbosity: int = 2,
interactive: boolean = True,
using: str = DEFAULT_DB_ALIAS,
apps: Apps = global_apps,
**kwargs: dict
) - > null

Creates default permissions for all models in a given application configuration. This function ensures that both ContentTypes and their associated Permission objects exist in the database, typically called during the post-migration signal.

Parameters

NameTypeDescription
app_configAppConfigThe configuration object for the application whose permissions should be generated.
verbosityint = 2Controls the amount of notification output printed to the console; levels 2 and higher list each added permission.
interactiveboolean = TrueDetermines if the function may prompt the user for input during the creation process.
usingstr = DEFAULT_DB_ALIASThe database alias identifying which database connection to use for permission lookups and creation.
appsApps = global_appsThe registry containing the installed application and model definitions.
**kwargsdictAdditional keyword arguments passed through to the underlying content type creation logic.

Returns

TypeDescription
nullNothing is returned; permissions are persisted directly to the database via bulk creation.