# Django Summary: Work with Django management commands. ## Common Options for Django Commands You will want to include `cd` to change to the project directory (where `manage.py` lives) and supply `venv` to load the virtual environment. ```ini [collect static files] django.static: cd: /path/to/project/source venv: ../python ``` ## Automatic Conversion of Django Command Switches Options provided in the command configuration file are automatically converted to command line switches. ```ini [run database migrations] django.migrate: settings: tenants.example_com.settings [dump some data] django.dump: projects.Category indent: 4 natural_foreign: yes natural_primary: yes ``` ## Available Commands ### check ```ini [run django checks] django.check: stop: yes ``` ### collectstatic Alias: static Collect static files. ```ini [collect static files] django.static: ``` ### createsuperuser Create a superuser account. ```ini [create the root user account] django.createsuperuser: root email: root@example.com ``` ### dumpdata Alias: dump Dump fixture data. - target (str): Required. The name of the app or `app.Model`. - format (str): `json` (default) or `xml`. - path (str): The path to the output file. When a model is provided, this defaults to `fixtures/app/model.json`. Otherwise, it is `fixtures/app/initial.json`. ```ini [dump project data] django.dump: projects [dump project categories] django.dump: projects.Category path: local/projects/fixtures/default-categories.json ``` ### loaddata Alias: load Load fixture data. - target (str): Required. The name of the app or `app.Model`. - format (str): `json` (default) or `xml` - path (str): The path to the JSON file. When a model is provided, this defaults to `fixtures/app/model.json`. Otherwise, it is `fixtures/app/initial.json`. ```ini [load project categories] django.load: projects path: local/projects/fixtures/default-categories.json ``` ### migrate Run database migrations. ```ini [run database migrations] django.migrate: stop: yes ``` ## Custom or Ad Hoc Commands It is possible to work with any Django management command provided the parameters may be specified as a switch. ```ini [run any django command] django: command_name first_option_name: asdf second_option_name: 1234 third_option_name: yes ``` This will generate a statement like: ```bash ./manage.py command_name --first-option-name="asdf" --second-option-name=1234 --third-option-name ```