Ticket #15515: django-15515.diff

File django-15515.diff, 4.0 KB (added by Joshua "jag" Ginsberg <jag@…>, 13 years ago)
  • django/core/management/base.py

    diff -r 86ae13d9baaf -r 302c8b593c9d django/core/management/base.py
    a b  
    357357        """
    358358        raise NotImplementedError()
    359359
    360 def copy_helper(style, app_or_project, name, directory, other_name=''):
     360def copy_helper(style, app_or_project, name, directory, other_name='',
     361                template_dir=None):
    361362    """
    362363    Copies either a Django application layout template or a Django project
    363364    layout template into the specified directory.
     
    385386    except OSError, e:
    386387        raise CommandError(e)
    387388
    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)
    392394
    393395    for d, subdirs, files in os.walk(template_dir):
    394396        relative_dir = d[len(template_dir)+1:].replace('%s_name' % app_or_project, name)
  • django/core/management/commands/startapp.py

    diff -r 86ae13d9baaf -r 302c8b593c9d django/core/management/commands/startapp.py
    a b  
    11import os
    2 
     2from optparse import make_option
    33from django.core.management.base import copy_helper, CommandError, LabelCommand
    44from django.utils.importlib import import_module
    55
     
    88    args = "[appname]"
    99    label = 'application name'
    1010
     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
    1119    requires_model_validation = False
    1220    # Can't import settings during this command, because they haven't
    1321    # necessarily been created.
     
    3341        else:
    3442            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)
    3543
    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'])
    3746
    3847class ProjectCommand(Command):
    3948    help = ("Creates a Django app directory structure for the given app name"
  • django/core/management/commands/startproject.py

    diff -r 86ae13d9baaf -r 302c8b593c9d django/core/management/commands/startproject.py
    a b  
    22from django.utils.importlib import import_module
    33import os
    44import re
     5from optparse import make_option
    56from random import choice
    67
    78class Command(LabelCommand):
     
    910    args = "[projectname]"
    1011    label = 'project name'
    1112
     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
    1221    requires_model_validation = False
    1322    # Can't import settings during this command, because they haven't
    1423    # necessarily been created.
     
    2736        else:
    2837            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)
    2938
    30         copy_helper(self.style, 'project', project_name, directory)
     39        copy_helper(self.style, 'project', project_name, directory,
     40                    template_dir=options['template_dir'])
    3141
    3242        # Create a random SECRET_KEY hash, and put it in the main settings.
    3343        main_settings_file = os.path.join(directory, project_name, 'settings.py')
Back to Top