From 98de57b27e373ce3b04dc95f092a290a8d8fbf87 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Tue, 6 Jan 2015 21:38:08 +0100 Subject: [PATCH] Added configurations.management.call_command. Fix #72. --- configurations/management.py | 3 ++- docs/cookbook.rst | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/configurations/management.py b/configurations/management.py index 01a7d58..e718ef5 100644 --- a/configurations/management.py +++ b/configurations/management.py @@ -2,4 +2,5 @@ from . import importer importer.install(check_options=True) -from django.core.management import execute_from_command_line # noqa +from django.core.management import (execute_from_command_line, # noqa + call_command) diff --git a/docs/cookbook.rst b/docs/cookbook.rst index 4575b8d..2999a03 100644 --- a/docs/cookbook.rst +++ b/docs/cookbook.rst @@ -1,6 +1,22 @@ Cookbook ======== +Calling a Django management command +----------------------------------- + +.. versionadded:: 1.0 + +If you want to call a Django management command programmatically, say +from a script outside of your usual Django code, you can use the +equivalent of Django's :func:`~django.core.management.call_command` function +with django-configurations, too. + +Simply import it from ``configurations.management`` instead:: + + from configurations.management import call_command + + call_command('dumpdata', exclude=['contenttypes', 'auth']) + Envdir ------