[Pythonmac-SIG] py2app and Django

Rob Hudson treborhudson at gmail.com
Fri Aug 4 21:09:04 CEST 2006


I appreciate the explanation and feedback.  I tried what you suggest and 
I can see that it does pull in the full django tree which is much easier 
and better.

This looks close but not quite there...

Here's the latest py2app-setup.py:

#!/usr/bin/env python
from setuptools import setup
setup(
         app=["run.py"],
         setup_requires=["py2app"],
         options=dict(py2app=dict(packages=["django","Quotes"],)),
)

Now I simply run this from within the Django-0.95 directory:
python py2app-setup.py py2app

And then launch Django:
# /dist/run.app/Contents/MacOS/run
Validating models...
Skipping validation because things aren't configured properly.
Django version 0.95, using settings 'Quotes.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Everytime the first page hit always produces the following error yet
concurrent page requests do not show this error.  This seems very odd
to me and suggests something strange is happening in Django...

Traceback (most recent call last):
   File "django/core/servers/basehttp.pyc", line 272, in run
   File "django/core/servers/basehttp.pyc", line 615, in __call__
   File "django/core/handlers/wsgi.pyc", line 143, in __call__
   File "django/core/handlers/base.pyc", line 31, in load_middleware
ImproperlyConfigured: Error importing middleware 
django.contrib.sessions.middleware: "cannot import name backend"
[04/Aug/2006 13:49:45] "GET / HTTP/1.1" 500 409

Requesting "/" again gives me an approriate error since I don't have the 
urls.py configured to do anything for this, and so this appears to work 
as it should:
[04/Aug/2006 13:49:50] "GET / HTTP/1.1" 404 1952

In the browser it shows this:

Using the URLconf defined in Quotes.urls, Django tried these URL
patterns, in this order:

    1. ^quote/$
    2. ^admin/

The current URL, /, didn't match any of these.

If I try to hit my "/quote/" page I get a 500 error at the terminal:
[04/Aug/2006 13:52:50] "GET /quote/ HTTP/1.1" 500 25750
this error in the browser:
ViewDoesNotExist at /quote/
Tried index in module Quotes.quotes.views. Error was: 'module' object
has no attribute 'Model'
Request Method: 	GET
Request URL: 	http://localhost:8000/quote/
Exception Type: 	ViewDoesNotExist
Exception Value: 	Tried index in module Quotes.quotes.views. Error was:
'module' object has no attribute 'Model'
Exception Location: 	<unknown> in ?, line ?

I do have an index method in my quotes/views.py and this works outside 
of py2app.  The error message is a bit confusing to me.

Trying "/admin/" I get another 500 error and the following:
ImportError at /admin/
No module named urls
Request Method: 	GET
Request URL: 	http://localhost:8000/admin/
Exception Type: 	ImportError
Exception Value: 	No module named urls
Exception Location: 	<unknown> in ?, line ?

Looking at the py2app output I can verify that
django.contrib.admin.urls is being pulled in.

I'm feeling like this is close.  Django successfully reports a 404.
But it is having trouble with my app and the admin so some parts seem
to be missing.

Thanks,
Rob



More information about the Pythonmac-SIG mailing list