Django project initial setup problems

I am learning Django from the official documentation and after going through the tutorial at https://docs.djangoproject.com/en/1.7/intro/tutorial01/ I get stuck creating part of the project.

When I run django-admin.py startproject mysite

I get the following error

C:\Python34>django-admin.py startproject mysite
Usage: django-admin.py subcommand [options] [args]
Options:
  -v VERBOSITY, --verbosity=VERBOSITY
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings=SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath=PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on exception
  --no-color            Don't colorize the command output.
  --version             show program version number and exit
  -h, --help            show this help message and exit
Type 'django-admin.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    makemessages
    makemigrations
    migrate
    runfcgi
    runserver
    shell
    sql
    sqlall
    sqlclear
    sqlcustom
    sqldropindexes
    sqlflush
    sqlindexes
    sqlinitialdata
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    syncdb
    test
    testserver
    validate

      

Note that only the basic Django commands are listed as the settings are not configured properly.

error: Requested setting INSTALLED_APPS, but settings are not configured
    . You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).

      

I am using Python 3.4.1 and django 1.7. I don't have another Django version and this is the first project I create.

+3


source to share


2 answers


Make sure you follow the troubleshooting guide because it looks like you don't have django-admin.py on your system path correctly. From the docs:

django-admin.py should be in your system path if you installed Django via python setup.py. If it's not in your path, you can find it in site-packages / django / bin, where site-packages is a directory inside your Python installation. Consider symbolically linking to django-admin.py from somewhere in your path like / usr / local / bin.



You should also use virtualenv for each of your projects to provide dependency isolation for each project and make it easier to manage. virtualenvwrapper is a useful tool for creating and managing your virtual files.

-1


source


You can simply run django-admin startproject mysite

(Note: not django-admin.py

), because if you install django by pip, an executable named 'django-admin.exe' will be added to 'C: \ Python34 \ Scripts' which is already in your variable environment "PATH" usually (if not, add it to PATH).



+18


source







All Articles