How to use startproject (django-admin.py) if django project already exists?

I am trying to start a new django project (using django-admin.py ), but unfortunately I always get the following error:

 C:\Users\NAME\dev\django>django-admin.py startproject foo Usage: django-admin.py subcommand [options] [args] [...] 

The same applies to any other django-admin.py command - each command does not exist.

I already have django projects (in C:\Users\NAME\dev\django\blog ) and I know that the startproject command is disabled if DJANGO_SETTINGS_MODULE set, but when I try this:

 >>> import os >>> os.environ['DJANGO_SETTINGS_MODULE'] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python26\lib\os.py", line 423, in __getitem__ return self.data[key.upper()] KeyError: 'DJANGO_SETTINGS_MODULE' 

Or even better:

 >>> from django.conf import settings >>> dir(settings) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python26\lib\site-packages\django\utils\functional.py", line 306, in __dir__ self._setup() File "C:\Python26\lib\site-packages\django\conf\__init__.py", line 38, in _set up raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE) ImportError: Settings cannot be imported, because environment variable DJANGO_SE TTINGS_MODULE is undefined. 

DJANGO_SETTINGS_MODULE seems to be undefined. Does anyone have an idea why I can't use django-admin.py ?

Django 1.2.3, Windows 7 (64 bit)

+4
source share
1 answer

DJANGO_SETTINGS_MODULE is only needed when you want to use django-admin.py with an existing Django project. Your problem seems different, it seems that django-admin.py for some reason does not evaluate the command line options. I have never tried this on Windows, but you tried doing something like:

 python django-admin.py startproject blog 

Now I also see that you are saying that you already have a blog project in this folder. Why do you need to run a project with the same name in the same folder? Please clarify what you are trying to achieve.

+4
source

Source: https://habr.com/ru/post/1336680/


All Articles