Skip to content
Browse files

render template files via django template engine.

context is provided from new setting EXTENSIONS_REPLACEMENTS
  • Loading branch information...
1 parent ffa0513 commit 515592af8014432e17f2d863ccfa21c8761b1405 @meshantz committed Sep 18, 2011
Showing with 12 additions and 1 deletion.
  1. +5 −1 django_extensions/management/commands/
  2. +7 −0 django_extensions/
6 django_extensions/management/commands/
@@ -4,6 +4,8 @@
from django.conf import settings
from django.db import connection
from import CommandError, LabelCommand, _make_writeable
+from django.template import Template, Context
+from django_extensions.settings import REPLACEMENTS
from django_extensions.utils.dia2django import dia2django
from optparse import make_option
@@ -85,6 +87,8 @@ def copy_template(app_template, copy_to, project_name, app_name):
for i, subdir in enumerate(subdirs):
if subdir.startswith('.'):
del subdirs[i]
+ replacements = {'app_name': app_name, 'project_name': project_name}
+ replacements.update(REPLACEMENTS)
for f in files:
if f.endswith('.pyc') or f.startswith('.DS_Store'):
@@ -98,7 +102,7 @@ def copy_template(app_template, copy_to, project_name, app_name):
path_new = path_new[:-5]
fp_old = open(path_old, 'r')
fp_new = open(path_new, 'w')
- fp_new.write('{{ app_name }}', app_name).replace('{{ project_name }}', project_name))
+ fp_new.write(Template(
7 django_extensions/
@@ -0,0 +1,7 @@
+from django.conf import settings
+add_replacements = getattr(settings, 'EXTENSIONS_REPLACEMENTS', {})

5 comments on commit 515592a

trbs commented on 515592a Oct 12, 2011

Does this work for you ? If so please do a pull request :) I would love to have the template files rendered by django-template renderer.


I've only used it a couple of times, but yeah it does seem to work. Haven't done a pull request before, so it may take me a little to get that done...

trbs commented on 515592a Oct 12, 2011

I've merged your branch into master. Could you please double check the merge ?

trbs commented on 515592a Oct 12, 2011
Please sign in to comment.
Something went wrong with that request. Please try again.