ちょっと戻って

こっちのページのソースを入れて

C:\Program Files\Google\google_appengine>dev_appserver.py C:\Python25\proj\appengine_helper_for_django-r52

 で django の起動には成功。

> http://localhost:8080/_ah/admin/datastore

 はうまくいったが、

> http://localhost:8080/polls/

 は、失敗。

ImportError at /polls/
No module named urls
Request Method: GET
Request URL: http://localhost:8080/polls/
Exception Type: ImportError
Exception Value: No module named urls
Exception Location: C:\Program Files\Google\google_appengine\lib\django\django\core\urlresolvers.py in _get_urlconf_module, line 177

 ちなみに、でたらめなページを指定すると

Page not found (404)
Request Method: GET
Request URL: http://localhost:8080/detarame/

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

1. ^polls/
2. ^shelf/

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

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

 と表示されるので、動いていることは動いているらしい。

        • -

 いったんシェルに戻って試す。

C:\Python25\proj\appengine_helper_for_django-r52>python manage.py shell
WARNING:root:Could not initialize images API; you are likely missing the Python
"PIL" module. ImportError: No module named PIL
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)

# PIL ってなに?

最新Pythonエクスプローラ pp12 の図2を参考にメンバー変数にアクセスすると、get メソッドが動いていない模様。

>>> from polls.models import Poll
>>> poll1 = Poll(question="987")
>>> poll1.save()
datastore_types.Key.from_path('Poll', 5L, _app=u'google-app-engine-django')
>>> Poll.objects.all()

>>> poll2 = Poll.objects.get(pk=1)
Traceback (most recent call last):
File "", line 1, in
TypeError: get() got an unexpected keyword argument 'pk'

 いろいろ調べては見たが、よく分からない。高速道路はまだ通っていないようだ。

An example of using Django on top of App Engineは datastore を直接アクセスする必要がありそうだし...。