Code

Ticket #20741: patch.diff

File patch.diff, 1.4 KB (added by palkeo, 12 months ago)
Line 
1diff --git a/django/core/management/templates.py b/django/core/management/templates.py
2index 1de508d..f31d33e 100644
3--- a/django/core/management/templates.py
4+++ b/django/core/management/templates.py
5@@ -53,7 +53,12 @@ class TemplateCommand(BaseCommand):
6                     action='append', default=[],
7                     help='The file name(s) to render. '
8                          'Separate multiple extensions with commas, or use '
9-                         '-n multiple times.')
10+                         '-n multiple times.'),
11+        make_option('--extra-context', '-c', dest='extra_context',
12+                    action='append', default=[],
13+                    help='Extra context to pass to template files to render. '
14+                         'Must be "variable_name=value". '
15+                         'You can use that option multiple times.'),
16         )
17     requires_model_validation = False
18     # Can't import settings during this command, because they haven't
19@@ -110,7 +115,9 @@ class TemplateCommand(BaseCommand):
20         else:
21             docs_version = '%d.%d' % django.VERSION[:2]
22 
23-        context = Context(dict(options, **{
24+        extra_context = dict(map(lambda a: a.split('=', 1), options['extra_context']))
25+
26+        context = Context(dict(extra_context, **{
27             base_name: name,
28             base_directory: top_dir,
29             'docs_version': docs_version,