django_evolution.compat.apps

Compatibility functions for the application registration.

This provides functions for app registration and lookup. These functions translate to the various versions of Django that are supported.

Functions

clear_app_cache()

Clear the Django app/models caches.

get_app(app_label[, emptyOK])

Return the app with the given label.

get_apps()

Return the list of all installed apps with models.

is_app_registered(app)

Return whether the app registry is tracking a given app.

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.compat.apps.clear_app_cache()

Clear the Django app/models caches.

This cache is used in Django >= 1.2 to quickly return results when fetching models. It needs to be cleared when modifying the model registry.

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

Return the app with the given label.

This returns the app from the app registry on Django >= 1.7, and from the old-style cache on Django < 1.7.

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.compat.apps.get_apps()

Return the list of all installed apps with models.

This returns the apps from the app registry on Django >= 1.7, and from the old-style cache on Django < 1.7.

Returns:

A list of all the modules containing model classes.

Return type:

list