Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #9092 -- Improved validation of app/project names by startapp/s…

…tartproject so that it doesn't allow names to start with a number.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9043 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 883aa6b9c8070d6946435c5f9783a49511830367 1 parent 772639c
@adrianholovaty adrianholovaty authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 django/core/management/base.py
View
9 django/core/management/base.py
@@ -194,8 +194,13 @@ def copy_helper(style, app_or_project, name, directory, other_name=''):
import re
import shutil
other = {'project': 'app', 'app': 'project'}[app_or_project]
- if not re.search(r'^\w+$', name): # If it's not a valid directory name.
- raise CommandError("%r is not a valid %s name. Please use only numbers, letters and underscores." % (name, app_or_project))
+ if not re.search(r'^[_a-zA-Z]\w*$', name): # If it's not a valid directory 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))
top_dir = os.path.join(directory, name)
try:
os.mkdir(top_dir)
Please sign in to comment.
Something went wrong with that request. Please try again.