diff --git a/django/core/management/commands/startapp.py b/django/core/management/commands/startapp.py
index 5581331..692ad09 100644
--- a/django/core/management/commands/startapp.py
+++ b/django/core/management/commands/startapp.py
@@ -9,8 +9,7 @@ class Command(TemplateCommand):
             "directory.")
 
     def handle(self, app_name=None, target=None, **options):
-        if app_name is None:
-            raise CommandError("you must provide an app name")
+        self.validate_name(app_name, "app")
 
         # Check that the app_name cannot be imported.
         try:
diff --git a/django/core/management/commands/startproject.py b/django/core/management/commands/startproject.py
index a1a9b33..b143e6c 100644
--- a/django/core/management/commands/startproject.py
+++ b/django/core/management/commands/startproject.py
@@ -10,8 +10,7 @@ class Command(TemplateCommand):
             "given directory.")
 
     def handle(self, project_name=None, target=None, *args, **options):
-        if project_name is None:
-            raise CommandError("you must provide a project name")
+        self.validate_name(project_name, "project")
 
         # Check that the project_name cannot be imported.
         try:
diff --git a/django/core/management/templates.py b/django/core/management/templates.py
index d34a0de..e75befc 100644
--- a/django/core/management/templates.py
+++ b/django/core/management/templates.py
@@ -64,21 +64,13 @@ class TemplateCommand(BaseCommand):
     # The supported URL schemes
     url_schemes = ['http', 'https', 'ftp']
 
+
     def handle(self, app_or_project, name, target=None, **options):
         self.app_or_project = app_or_project
         self.paths_to_remove = []
         self.verbosity = int(options.get('verbosity'))
 
-        # 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))
+        self.validate_name(name, app_or_project)
 
         # if some directory is given, make sure it's nicely expanded
         if target is None:
@@ -211,6 +203,20 @@ class TemplateCommand(BaseCommand):
         raise CommandError("couldn't handle %s template %s." %
                            (self.app_or_project, template))
 
+    def validate_name(self, name, app_or_project):
+        if name is None:
+            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))
+
     def download(self, url):
         """
         Downloads the given URL and returns the file name.
diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py
index 6f524be..a9a9728 100644
--- a/tests/regressiontests/admin_scripts/tests.py
+++ b/tests/regressiontests/admin_scripts/tests.py
@@ -1428,12 +1428,27 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
 
         args = ['startproject', '7testproject']
         testproject_dir = os.path.join(test_dir, '7testproject')
+        self.addCleanup(cleanup, testproject_dir)
 
         out, err = self.run_django_admin(args)
-        self.addCleanup(cleanup, testproject_dir)
         self.assertOutput(err, "Error: '7testproject' is not a valid project name. Please make sure the name begins with a letter or underscore.")
         self.assertFalse(os.path.exists(testproject_dir))
 
+    def test_path_as_project_name(self):
+        "Make sure the startproject management command validates a project name"
+
+        def cleanup(p):
+            if os.path.exists(p):
+                shutil.rmtree(p)
+
+        args = ['startproject', '../testproject']
+        testproject_dir = os.path.join(test_dir, '../testproject')
+        self.addCleanup(cleanup, testproject_dir)
+
+        out, err = self.run_django_admin(args)
+        self.assertOutput(err, "Error: '../testproject' is not a valid project name. Please make sure the name begins with a letter or underscore.")
+        self.assertFalse(os.path.exists(testproject_dir))
+
     def test_simple_project_different_directory(self):
         "Make sure the startproject management command creates a project in a specific directory"
         args = ['startproject', 'testproject', 'othertestproject']
