summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authoroliver <myungsekyo@gmail.com>2019-03-30 23:14:07 +0900
committerTim Graham <timograham@gmail.com>2019-03-30 10:14:07 -0400
commit03bee42a7e28b1bbd6bb8df03b9e9bdd54f44837 (patch)
tree5e7be01a40cecf077fbbafeeb2700751e8d4e231 /django
parent96446c7152c115beee925bbd1f3273a3634d7983 (diff)
Made startapp/project's overlaying error message use 'app' or 'project'.
Diffstat (limited to 'django')
-rw-r--r--django/core/management/templates.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/django/core/management/templates.py b/django/core/management/templates.py
index 299b36b6df..0e9adfeb09 100644
--- a/django/core/management/templates.py
+++ b/django/core/management/templates.py
@@ -58,10 +58,11 @@ class TemplateCommand(BaseCommand):
def handle(self, app_or_project, name, target=None, **options):
self.app_or_project = app_or_project
+ self.a_or_an = 'an' if app_or_project == 'app' else 'a'
self.paths_to_remove = []
self.verbosity = options['verbosity']
- self.validate_name(name, app_or_project)
+ self.validate_name(name)
# if some directory is given, make sure it's nicely expanded
if target is None:
@@ -139,10 +140,12 @@ class TemplateCommand(BaseCommand):
break # Only rewrite once
if path.exists(new_path):
- raise CommandError("%s already exists, overlaying a "
- "project or app into an existing "
- "directory won't replace conflicting "
- "files" % new_path)
+ raise CommandError(
+ "%s already exists. Overlaying %s %s into an existing "
+ "directory won't replace conflicting files." % (
+ new_path, self.a_or_an, app_or_project,
+ )
+ )
# Only render the Python files, as we don't want to
# accidentally render Django templates files
@@ -202,12 +205,11 @@ class TemplateCommand(BaseCommand):
raise CommandError("couldn't handle %s template %s." %
(self.app_or_project, template))
- def validate_name(self, name, app_or_project):
- a_or_an = 'an' if app_or_project == 'app' else 'a'
+ def validate_name(self, name):
if name is None:
raise CommandError('you must provide {an} {app} name'.format(
- an=a_or_an,
- app=app_or_project,
+ an=self.a_or_an,
+ app=self.app_or_project,
))
# Check it's a valid directory name.
if not name.isidentifier():
@@ -215,7 +217,7 @@ class TemplateCommand(BaseCommand):
"'{name}' is not a valid {app} name. Please make sure the "
"name is a valid identifier.".format(
name=name,
- app=app_or_project,
+ app=self.app_or_project,
)
)
# Check it cannot be imported.
@@ -229,8 +231,8 @@ class TemplateCommand(BaseCommand):
"module and cannot be used as {an} {app} name. Please try "
"another name.".format(
name=name,
- an=a_or_an,
- app=app_or_project,
+ an=self.a_or_an,
+ app=self.app_or_project,
)
)