Code

Ticket #8329: startproj.diff

File startproj.diff, 2.0 KB (added by IanHolsman, 6 years ago)

patch to add a warning

Line 
1Index: django/core/management/base.py
2===================================================================
3--- django/core/management/base.py      (revision 8354)
4+++ django/core/management/base.py      (working copy)
5@@ -169,6 +169,19 @@
6     def handle_label(self, label, **options):
7         raise NotImplementedError()
8 
9+class InvalidStartProjectContextCommand(BaseCommand):
10+    args = ''
11+
12+    def handle(self, *args, **options):
13+        #if args:
14+        raise CommandError("The startproject command has been disabled as you have a project defined. Hint unset your DJANGO_SETTINGS_MODULE environment variable")
15+        #return self.handle_noargs(**options)
16+
17+    def handle_noargs(self, **options):
18+        raise CommandError("The startproject command has been disabled as you have a project defined. Hint unset your DJANGO_SETTINGS_MODULE environment variable")
19+        #raise NotImplementedError()
20+
21+
22 class NoArgsCommand(BaseCommand):
23     args = ''
24 
25Index: django/core/management/__init__.py
26===================================================================
27--- django/core/management/__init__.py  (revision 8354)
28+++ django/core/management/__init__.py  (working copy)
29@@ -4,7 +4,7 @@
30 from imp import find_module
31 
32 import django
33-from django.core.management.base import BaseCommand, CommandError, handle_default_options
34+from django.core.management.base import BaseCommand, CommandError, handle_default_options, InvalidStartProjectContextCommand
35 
36 # For backwards compatibility: get_version() used to be in this module.
37 get_version = django.get_version
38@@ -125,7 +125,8 @@
39         if project_directory:
40             # Remove the "startproject" command from self.commands, because
41             # that's a django-admin.py command, not a manage.py command.
42-            del _commands['startproject']
43+            #del _commands['startproject']
44+            _commands['startproject'] = InvalidStartProjectContextCommand()
45 
46             # Override the startapp command so that it always uses the
47             # project_directory, not the current working directory