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
|
b
|
class TemplateCommand(BaseCommand):
|
51 | 51 | action='append', default=[], |
52 | 52 | help='The file name(s) to render. ' |
53 | 53 | 'Separate multiple extensions with commas, or use ' |
54 | | '-n multiple times.') |
| 54 | '-n multiple times.'), |
| 55 | make_option('--add_context', '-a', dest='add_context', |
| 56 | action='append', default=[], |
| 57 | help='A key:value parameter to be rendered in the template.' |
| 58 | 'Separate multiple variables with commas, like this:' |
| 59 | '-a foo:bar,one:two or use -a multiple times.') |
55 | 60 | ) |
56 | 61 | requires_model_validation = False |
57 | 62 | # Can't import settings during this command, because they haven't |
… |
… |
class TemplateCommand(BaseCommand):
|
110 | 115 | base_subdir = '%s_template' % app_or_project |
111 | 116 | base_directory = '%s_directory' % app_or_project |
112 | 117 | |
113 | | context = Context(dict(options, **{ |
| 118 | added_context = { |
114 | 119 | base_name: name, |
115 | 120 | base_directory: top_dir, |
116 | | })) |
| 121 | } |
| 122 | |
| 123 | # adding optional template variables passed in the command |
| 124 | for param in options['add_context'][0].split(','): |
| 125 | added_context[str(param.split(':')[0])] = param.split(':')[1] |
| 126 | |
| 127 | context = Context(dict(options, **added_context)) |
117 | 128 | |
118 | 129 | # Setup a stub settings environment for template rendering |
119 | 130 | 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
|
b
|
through the template engine: the files whose extensions match the
|
909 | 909 | with the ``--name`` option. The :class:`template context |
910 | 910 | <django.template.Context>` used is: |
911 | 911 | |
912 | | - Any option passed to the startapp command |
| 912 | - Any option passed to the startapp command through the ``--add_context`` option |
913 | 913 | - ``app_name`` -- the app name as passed to the command |
914 | 914 | - ``app_directory`` -- the full path of the newly created app |
915 | 915 | |
… |
… |
through the template engine: the files whose extensions match the
|
972 | 972 | with the ``--name`` option. The :class:`template context |
973 | 973 | <django.template.Context>` used is: |
974 | 974 | |
975 | | - Any option passed to the startproject command |
| 975 | - Any option passed to the startproject command through the ``--add_context`` option |
976 | 976 | - ``project_name`` -- the project name as passed to the command |
977 | 977 | - ``project_directory`` -- the full path of the newly created project |
978 | 978 | - ``secret_key`` -- a random key for the :setting:`SECRET_KEY` setting |