diff -r 86ae13d9baaf -r 302c8b593c9d django/core/management/base.py
a
|
b
|
|
357 | 357 | """ |
358 | 358 | raise NotImplementedError() |
359 | 359 | |
360 | | def copy_helper(style, app_or_project, name, directory, other_name=''): |
| 360 | def copy_helper(style, app_or_project, name, directory, other_name='', |
| 361 | template_dir=None): |
361 | 362 | """ |
362 | 363 | Copies either a Django application layout template or a Django project |
363 | 364 | layout template into the specified directory. |
… |
… |
|
385 | 386 | except OSError, e: |
386 | 387 | raise CommandError(e) |
387 | 388 | |
388 | | # Determine where the app or project templates are. Use |
389 | | # django.__path__[0] because we don't know into which directory |
390 | | # django has been installed. |
391 | | template_dir = os.path.join(django.__path__[0], 'conf', '%s_template' % app_or_project) |
| 389 | if not template_dir: |
| 390 | # Determine where the app or project templates are. Use |
| 391 | # django.__path__[0] because we don't know into which directory |
| 392 | # django has been installed. |
| 393 | template_dir = os.path.join(django.__path__[0], 'conf', '%s_template' % app_or_project) |
392 | 394 | |
393 | 395 | for d, subdirs, files in os.walk(template_dir): |
394 | 396 | relative_dir = d[len(template_dir)+1:].replace('%s_name' % app_or_project, name) |
diff -r 86ae13d9baaf -r 302c8b593c9d django/core/management/commands/startapp.py
a
|
b
|
|
1 | 1 | import os |
2 | | |
| 2 | from optparse import make_option |
3 | 3 | from django.core.management.base import copy_helper, CommandError, LabelCommand |
4 | 4 | from django.utils.importlib import import_module |
5 | 5 | |
… |
… |
|
8 | 8 | args = "[appname]" |
9 | 9 | label = 'application name' |
10 | 10 | |
| 11 | option_list = LabelCommand.option_list + ( |
| 12 | make_option('--template', |
| 13 | action='store', |
| 14 | dest='template_dir', |
| 15 | default=None, |
| 16 | help='Path to a custom project template'), |
| 17 | ) |
| 18 | |
11 | 19 | requires_model_validation = False |
12 | 20 | # Can't import settings during this command, because they haven't |
13 | 21 | # necessarily been created. |
… |
… |
|
33 | 41 | else: |
34 | 42 | raise CommandError("%r conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name." % app_name) |
35 | 43 | |
36 | | copy_helper(self.style, 'app', app_name, directory, project_name) |
| 44 | copy_helper(self.style, 'app', app_name, directory, project_name, |
| 45 | template_dir=options['template_dir']) |
37 | 46 | |
38 | 47 | class ProjectCommand(Command): |
39 | 48 | help = ("Creates a Django app directory structure for the given app name" |
diff -r 86ae13d9baaf -r 302c8b593c9d django/core/management/commands/startproject.py
a
|
b
|
|
2 | 2 | from django.utils.importlib import import_module |
3 | 3 | import os |
4 | 4 | import re |
| 5 | from optparse import make_option |
5 | 6 | from random import choice |
6 | 7 | |
7 | 8 | class Command(LabelCommand): |
… |
… |
|
9 | 10 | args = "[projectname]" |
10 | 11 | label = 'project name' |
11 | 12 | |
| 13 | option_list = LabelCommand.option_list + ( |
| 14 | make_option('--template', |
| 15 | action='store', |
| 16 | dest='template_dir', |
| 17 | default=None, |
| 18 | help='Path to a custom project template'), |
| 19 | ) |
| 20 | |
12 | 21 | requires_model_validation = False |
13 | 22 | # Can't import settings during this command, because they haven't |
14 | 23 | # necessarily been created. |
… |
… |
|
27 | 36 | else: |
28 | 37 | raise CommandError("%r conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name." % project_name) |
29 | 38 | |
30 | | copy_helper(self.style, 'project', project_name, directory) |
| 39 | copy_helper(self.style, 'project', project_name, directory, |
| 40 | template_dir=options['template_dir']) |
31 | 41 | |
32 | 42 | # Create a random SECRET_KEY hash, and put it in the main settings. |
33 | 43 | main_settings_file = os.path.join(directory, project_name, 'settings.py') |