API¶
app_manage.core
¶
-
app_manage.core.
main
(apps, *, argv=sys.argv, environ=os.environ, *args, **config)¶ Main entry point into django-app-manage. Configures Django and then runs the command passed in
argv
(orsys.argv
).Parameters: - apps (list) – List of app names (as strings). These will be auto-added to
INSTALLED_APPS
. - argv (list) – List of arguments, you shouldn’t need to have to set this value yourself.
- environ (dict) – Environment dictionary, you shouldn’t need to have to set this value yourself.
- args – Arguments to configure your app. Must be instances of
app_manage.config.Argument
. - config – Django configuration to use in your app. Values can be instances of
app_manage.config.DynamicSetting
subclasses if you want them to be configurable.
- apps (list) – List of app names (as strings). These will be auto-added to
app_manage.config
¶
-
class
app_manage.config.
DynamicSetting
¶ Base class for all your dynamic settings. Must be subclassed.
-
get_value
(argv, environ)¶ This method must be implemented by subclasses.
Given the arguments and environment, returns the value to be used for the given setting.
argv
can and should be modified by this method where applicable.Parameters: - argv (list) – List of arguments.
- environ (dict) – Environment dictionary.
-
cleanup
()¶ Optional method that can be used to do any cleanup where necessary after the Django command finished executing.
-
-
class
app_manage.config.
TempDir
¶ DynamicSetting
subclass that returns a path to a temporary directory and removes that directory after the Django command executed.Useful for
MEDIA_ROOT
and similar settings.
-
class
app_manage.config.
Config
(env=None, arg=None, default=NULL)¶ The bread-and-butter class to configure your app.
env
is the key in the environment dictionary andarg
the name of the command line argument (must include leading dashes, for example'--arg'
).Command line arguments override environment variables.
-
class
app_manage.config.
DatabaseConfig
¶ Helper class that runs the value passed through dj_database_url.
-
class
app_manage.config.
Flag
(name)¶ Can be used as the
arg
argument to aConfig
instance to indicate a boolean flag instead of a command line argument.
-
class
app_manage.config.
Argument
(config, callback)¶ Class used to do more complex configurations that affect multiple settings. Instances of this class are passed as
args
toapp_manage.core.main()
.config
is an instance of aDynamicSetting
subclass andcallback
is a callable with the following signature:-
callback
(settings, value)¶ Parameters: - settings (dict) – Dictionary holding Django settings
- value – The value returned by
config
.
-