pythondjangowindowsgoogle-app-enginedjango-nonrel

django-nonrel for AppEngine on Windows


I'm having trouble with something that should be relatively simply- getting a django-nonrel project off the ground on a Windows machine. I have downloaded and unzipped the required files from http://djangoappengine.readthedocs.org/en/latest/installation.html, added the required modules to my projects root folder C:\djangoapp, such that the folder hierarchy is (note each module contains the correct files, and have been omitted for the sake of brevity)

djangoapp/
     autoload/
     dbindexer/
     django/
     djangoappengine/
     djangotoolbox/

Now when I cd into C:\djangoapp, I need to know the command to run. The given command:

PYTHONPATH=. python django/bin/django-admin.py startproject \
--name=app.yaml --template=djangoappengine/conf/project_template myapp .

is for a *NIX OS and obviously won't work on Windows. Simply doing,

python django/bin/django-admin.py startproject \
--name=app.yaml --template=djangoappengine/conf/project_template myapp

returns this error:

 Traceback (most recent call last):
File "django/bin/django-admin.py", line 2, in <module>
 from django.core import management
ImportError: No module named django.core

Obviously there is an issue with PYTHONPATH as the given Unix command starts with PYTHONPATH=. How would I execute the equivalent on a Windows box to get django-nonrel up and running? Thanks in advance!

P.S. Just for the sake of learning, could someone break down the given unix command, as far as what the periods and the backslash are doing. Thanks, again!

****** UPDATE IN RESPONSE TO Answer *******

Thanks a ton, Nick! You answered every part of my question, and the solution worked perfectly. Unfortunately the next step,

python manage.py runserver

ran into a strange error:

File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\testbed\__init__.py", line 585, in init_images_stub
    raise StubNotSupportedError(msg)
google.appengine.ext.testbed.StubNotSupportedError: Could not initialize images API; you are likely missing the Python "PIL" module.

Obviously not the right solution, but I just went to the file location and commented out the relevant block dealing with image stub, and the server started up fine. If anyone knows an actual solution, let me know while I look into it a little more!

Thanks again


Solution

  • In the original command, PYTHONPATH=. is setting the environment variable PYTHONPATH to ., which is a special symbol for the current directory. I think both env vars and a special symbol for the current directory exist in windows CMD, although this particular syntax doesn't translate. The special dot character is also used at the end of the command, after myapp.

    This means that the python path will include the current directory, and the interpreter will look for referenced modules within the current directory.

    The backslash is used just before a newline character, so as to not disrupt the interpretation of the command.

    Elsewhere on the internet (for example this SO question), you can find examples of how to set environment variables in the context of windows CMD.

    The current directory symbol in windows is %CD%.

    In linux, you can set environment variables in the same line as another command, but in windows, you will need to set it as a command prior to the main command.

    In windows, you might need to make a .cmd file and have it contain:

    set PYTHONPATH=%CD%
    python django/bin/django-admin.py startproject --name=app.yaml --template=djangoappengine/conf/project_template myapp %CD%