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:

  • --src dir_name

    • Name of the directory that holds the module definition. If not provided, src is assumed

  • --module mod_name

    • Name of the module to add to the INSTALLED_APPS settings

  • --test dir_name

    • Name of the directory where tests can be found. If not provided, looks for tests, otherwise acts as if there are none.

  • --noawl

    • Flag to indicate that the awl app should not be included in the resulting environment

  • --root_url text

    • Provide a value for the ROOT_URL setting

  • --template_dirs text

    • Comma separated list of directory names where Django looks for templates

  • --config text

    • JSON dictionary to be used as **kwargs in the call that defines settings.py values

  • --shebang text

    • Contents for the first line in the output script. On systems where os.name returns ‘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.