From aa25e5bf1223039bf9100db4ea2b7269455ce1b7 Mon Sep 17 00:00:00 2001
From: Dominique Guardiola <dguardiola@quinode.fr>
Date: Mon, 7 May 2012 11:10:49 +0200
Subject: [PATCH] --add_context option in start project command to allow what
 was intended in the documentation

---
 django/core/management/templates.py |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/django/core/management/templates.py b/django/core/management/templates.py
index 735e29a..9fc49cc 100644
--- a/django/core/management/templates.py
+++ b/django/core/management/templates.py
@@ -51,7 +51,12 @@ class TemplateCommand(BaseCommand):
                     action='append', default=[],
                     help='The file name(s) to render. '
                          'Separate multiple extensions with commas, or use '
-                         '-n multiple times.')
+                         '-n multiple times.'),
+        make_option('--add_context', '-a', dest='add_context',
+                    action='append', default=[],
+                    help='A key:value parameter to be rendered in the template.'
+                         'Separate multiple variables with commas, like this:'
+                         '-a foo:bar,one:two or use -a multiple times.')
         )
     requires_model_validation = False
     # Can't import settings during this command, because they haven't
@@ -110,10 +115,16 @@ class TemplateCommand(BaseCommand):
         base_subdir = '%s_template' % app_or_project
         base_directory = '%s_directory' % app_or_project
 
-        context = Context(dict(options, **{
+        added_context = {
             base_name: name,
             base_directory: top_dir,
-        }))
+        }
+
+        # adding optional template variables passed in the command
+        for param in options['add_context'][0].split(','):
+            added_context[str(param.split(':')[0])] = param.split(':')[1]
+
+        context = Context(dict(options, **added_context))
 
         # Setup a stub settings environment for template rendering
         from django.conf import settings
-- 
1.7.8.3

From 2b74195fae34138ab39cbd97819dbae8fd6e2901 Mon Sep 17 00:00:00 2001
From: Dominique Guardiola <dguardiola@quinode.fr>
Date: Mon, 7 May 2012 11:26:44 +0200
Subject: [PATCH] doc modification

---
 docs/ref/django-admin.txt |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index 0ea8252..093619b 100644
--- a/docs/ref/django-admin.txt
+++ b/docs/ref/django-admin.txt
@@ -909,7 +909,7 @@ through the template engine: the files whose extensions match the
 with the ``--name`` option. The :class:`template context
 <django.template.Context>` used is:
 
-- Any option passed to the startapp command
+- Any option passed to the startapp command through the ``--add_context`` option
 - ``app_name`` -- the app name as passed to the command
 - ``app_directory`` -- the full path of the newly created app
 
@@ -972,7 +972,7 @@ through the template engine: the files whose extensions match the
 with the ``--name`` option. The :class:`template context
 <django.template.Context>` used is:
 
-- Any option passed to the startproject command
+- Any option passed to the startproject command through the ``--add_context`` option
 - ``project_name`` -- the project name as passed to the command
 - ``project_directory`` -- the full path of the newly created project
 - ``secret_key`` -- a random key for the :setting:`SECRET_KEY` setting
-- 
1.7.8.3

