django_evolution.utils.apps

Utilities for working with apps.

Functions

get_app(app_label[, emptyOK])

Return the app with the given label.

get_app_config_for_app(app)

Return the app configuration for an app.

get_app_label(app)

Return the label of an app.

get_app_name(app)

Return the name of an app.

get_apps()

Return the list of all installed apps with models.

get_legacy_app_label(app)

Return the label of an app.

import_management_modules()

Import the management modules for all apps.

register_app(app_label, app)

Register a new app in the registry.

register_app_models(app_label, model_infos)

Register one or more models to a given app.

unregister_app(app_label)

Unregister an app in the registry.

unregister_app_model(app_label, model_name)

Unregister a model with the given name from the given app.

django_evolution.utils.apps.get_apps()

Return the list of all installed apps with models.

Changed in version 3.0: Moved from django.compat.apps.

Returns:

A list of all the modules containing model classes.

Return type:

list

django_evolution.utils.apps.get_app(app_label, emptyOK=False)

Return the app with the given label.

Changed in version 3.0: Moved from django.compat.apps.

Parameters:
  • app_label (str) – The label for the app containing the models.

  • emptyOK (bool, optional) – Impacts the return value if the app has no models in it.

Returns:

The app module, if available.

If the app module is available, but the models module is not and emptyOK is set, this will return None. Otherwise, if modules are not available, this will raise ImproperlyConfigured.

Return type:

module

Raises:

django.core.exceptions.ImproperlyConfigured – The app module was not found, or it was found but a models module was not and emptyOK was False.

django_evolution.utils.apps.get_app_config_for_app(app)

Return the app configuration for an app.

This can only be called if running on Django 1.7 or higher.

Parameters:

app (module) – The app’s models module to return the configuration for. The models module is used for legacy reasons within Django Evolution.

Returns:

The app configuration, or None if it couldn’t be found.

Return type:

django.apps.AppConfig

django_evolution.utils.apps.get_app_label(app)

Return the label of an app.

Parameters:

app (module) – The app.

Returns:

The label of the app.

Return type:

str

django_evolution.utils.apps.get_app_name(app)

Return the name of an app.

Parameters:

app (module) – The app.

Returns:

The name of the app.

Return type:

str

django_evolution.utils.apps.get_legacy_app_label(app)

Return the label of an app.

Parameters:

app (module) – The app.

Returns:

The label of the app.

Return type:

str

django_evolution.utils.apps.import_management_modules()

Import the management modules for all apps.

Management modules often contain signal handlers for pre/post syncdb/migrate events. This will import them correctly for the current version of Django.

Raises:

ImportError – A management module failed to import.

django_evolution.utils.apps.register_app(app_label, app)

Register a new app in the registry.

This must be balanced with a unregister_app() call.

Changed in version 3.0: Moved from django.compat.apps.

Parameters:
  • app_label (str) – The label of the app.

  • app (module) – The app module.

django_evolution.utils.apps.unregister_app(app_label)

Unregister an app in the registry.

This must be balanced with a register_app() call.

Changed in version 3.0: Moved from django.compat.apps.

Parameters:

app_label (str) – The label of the app to register.

django_evolution.utils.apps.register_app_models(app_label, model_infos, reset=False)

Register one or more models to a given app.

These will add onto the list of existing models.

Changed in version 3.0: Moved from django.compat.apps.

Parameters:
  • app_label (str) – The label of the app to register the models on.

  • model_info (list) – A list of pairs of (model name, model class) to register.

  • reset (bool, optional) – If set, the old list will be overwritten with the new list.

django_evolution.utils.apps.unregister_app_model(app_label, model_name)

Unregister a model with the given name from the given app.

Changed in version 3.0: Moved from django.compat.apps.

Parameters:
  • app_label (str) – The label of the app containing a model.

  • model_name (str) – The name of the model to unregister.