Ticket #1908: directory_name_fix.diff

File directory_name_fix.diff, 1.4 KB (added by yasar11732, 3 years ago)

Fixes comment 12

  • django/core/management/commands/startapp.py

    diff --git a/django/core/management/commands/startapp.py b/django/core/management/commands/startapp.py
    index 13d6483..7612520 100644
    a b import os 
    33from django.core.management.base import copy_helper, CommandError, LabelCommand
    44from django.utils.importlib import import_module
    55
     6# to check if upper level directory is really a django project
     7std_project_files = ("manage.py","urls.py")
     8
    69class Command(LabelCommand):
    710    help = "Creates a Django app directory structure for the given app name in the current directory."
    811    args = "[appname]"
    class Command(LabelCommand): 
    2124        # which should be the full path of the project directory (or the
    2225        # current directory if no directory was passed).
    2326        project_name = os.path.basename(directory)
     27       
    2428        if app_name == project_name:
    25             raise CommandError("You cannot create an app with the same name"
     29            for filename in std_project_files:
     30                if not os.path.isfile(os.path.join(project_name,filename)):
     31                    break
     32            else:
     33                raise CommandError("You cannot create an app with the same name"
    2634                               " (%r) as your project." % app_name)
    2735
    2836        # Check that the app_name cannot be imported.
Back to Top