summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorYoong Kang Lim <yoongkang.lim@gmail.com>2015-10-22 22:33:59 +1100
committerTim Graham <timograham@gmail.com>2015-10-22 13:01:07 -0400
commit3f300efede9f9670f4c413ff85ad731def15992b (patch)
tree0618ad15e0c26601a6f7f532f596408e56e5c647 /django
parentee66d8dd7df8326c453fd04c2bdeb5225df934be (diff)
Fixed #25589 -- Allowed startapp/project to create apps with Unicode characters in the name.
Diffstat (limited to 'django')
-rw-r--r--django/core/management/templates.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/django/core/management/templates.py b/django/core/management/templates.py
index 3addb068f7..7c147a5231 100644
--- a/django/core/management/templates.py
+++ b/django/core/management/templates.py
@@ -208,14 +208,21 @@ class TemplateCommand(BaseCommand):
raise CommandError("you must provide %s %s name" % (
"an" if app_or_project == "app" else "a", app_or_project))
# If it's not a valid directory name.
- if not re.search(r'^[_a-zA-Z]\w*$', name):
- # Provide a smart error message, depending on the error.
- if not re.search(r'^[_a-zA-Z]', name):
- message = 'make sure the name begins with a letter or underscore'
- else:
- message = 'use only numbers, letters and underscores'
- raise CommandError("%r is not a valid %s name. Please %s." %
- (name, app_or_project, message))
+ if six.PY2:
+ if not re.search(r'^[_a-zA-Z]\w*$', name):
+ # Provide a smart error message, depending on the error.
+ if not re.search(r'^[_a-zA-Z]', name):
+ message = 'make sure the name begins with a letter or underscore'
+ else:
+ message = 'use only numbers, letters and underscores'
+ raise CommandError("%r is not a valid %s name. Please %s." %
+ (name, app_or_project, message))
+ else:
+ if not name.isidentifier():
+ raise CommandError(
+ "%r is not a valid %s name. Please make sure the name is "
+ "a valid identifier." % (name, app_or_project)
+ )
def download(self, url):
"""