Search code examples
pythondjangobuildout

django runserver can't find django


I'm creating a Django application and I've compiled my own Python then used buildout to manage my dependencies.

I'm at the point where I want to run manage.py runserver but I can get an ImportError for django

Digging a little deeper it appears that actually it can find django - if I just run manage.py it lists all available commands (so obviously it imported django), but it appears that manage.py runserver calls manage.py again, and I guess this must be calling Python without the overloaded path that buildout provides.

So, how can I get manage.py runserver to work with my given setup? Other tutorials I see all say to use virtualenv but I've gone down the path of compiling my own Python so I'd like to stick with that. I've also seen similar questions but they seem to assume the use of system Python, which I am not using. Possibly Django should be installed into my compiled Python but I thought the point of buildout was to avoid the need to do that.


Solution

  • So, I think I figured it out. I found a file called django-admin.py in my buildout's bin directory, which eventually led me to add a django section to my buildout.cfg (see https://pypi.python.org/pypi/djangorecipe for details).

    This created a file called django in my buildout's bin directory, and now running bin/django runserver allows me to view my site locally.