Installable Django App Tools
When writing installable Django Apps, you need a hook to be able to run and
test them within a Django environment. The makemanage command creates a
manage.py file for you in your project directory with exactly those hooks.
By default, makemanage looks for a “src” directory with a single module
inside of it as well as a directory named “tests”. You can configure those
directories along with other parameters as well. The resulting manage.py
script calls awl.appmanage.boot_django() to configure your environment.
Command line arguments to makemanage are:
--srcdir_nameName of the directory that holds the module definition. If not provided,
srcis assumed
--modulemod_nameName of the module to add to the
INSTALLED_APPSsettings
--testdir_nameName of the directory where tests can be found. If not provided, looks for
tests, otherwise acts as if there are none.
--noawlFlag to indicate that the
awlapp should not be included in the resulting environment
--root_urltextProvide a value for the
ROOT_URLsetting
--template_dirstextComma separated list of directory names where Django looks for templates
--configtextJSON dictionary to be used as
**kwargsin the call that definessettings.pyvalues
--shebangtextContents for the first line in the output script. On systems where
os.namereturns ‘posix’, defaults to ‘#!/usr/bin/env python’, otherwise empty
- awl.appmanage.boot_django(module_dir, test_dir=None, root_url=None, template_dirs=None, noawl=False, config_kwargs=None)
Configures a Django instance including your standalone app. The instance is in DEBUG mode with an sqlite3 database.
- Parameters:
module_dir – Pathlib.Path object pointing to the app’s module directory. Adds its parent directory to Python’s module path.
test_dir – (Optional) Pathlib.Path object pointing to directory where tests reside. Adds this directory to Python’s module path.
root_url – (Optional) Value for the ROOT_URL parameter
template_dirs – List of directories for templates. Defaults to []
noawl – True to stop the inclusion of the awl library in INSTALLED APPS
config_kwargs – A JSON dictionary of keyword arguments to add to the configuration call. This should contain any additional definitions you would normally put in your settings.py file. Note that this is called as an update to the configuration and can be used to overwrite default configuration.