Reputation: 5391
I'm trying to install Google App Engine with Django 1.1 on Windows.
When launching the App Engine I'm getting the following error: http://slexy.org/view/s21oLrbkHh
The steps I do are:
My main.py code is attached below. I'm falling on line: "import django.db" which I can do successfully from cmd.
Do you have an idea?
main.py:
\# main.py
import os, sys
os.environ["DJANGO\_SETTINGS\_MODULE"] = "taskhood.settings"
sys.path.append("/home/brox/tmp/mashname")
\# Google App Engine imports.
from google.appengine.ext.webapp import util
\# Django version
from google.appengine.dist import use_library
use_library('django', '1.1')
\# Force Django to reload its settings.
from django.conf import settings
settings._target = None
import django.core.handlers.wsgi
import django.core.signals
import django.db
import django.dispatch.dispatcher
def log_exception(*args, **kwds):
logging.exception('Exception in request:')
\# Log errors.
django.dispatch.Signal.connect(
django.core.signals.got_request_exception,
log_exception)
\# Unregister the rollback event handler.
django.dispatch.Signal.disconnect(
django.core.signals.got_request_exception,
django.db._rollback_on_exception)
def main():
# Create a Django application for WSGI.
application = django.core.handlers.wsgi.WSGIHandler()
# Run the WSGI CGI handler with that application.
util.run_wsgi_app(application)
if __name__ == "__main__":
main()
Upvotes: 0
Views: 649
Reputation: 23950
Django 1.1 is not the default version on App Engine, use 0.96 in stead or specify that you want to use 1.1. See this article on goodle code.
For that matter, the models need to be adapted as App Engine does not have a regular (sql) database. That's also described on the given link.
Upvotes: 0
Reputation: 46264
Make sure your DB configuration in your settings.py
is blank:
DATABASE_ENGINE = ''
DATABASE_NAME = ''
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''
Along with the following:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
)
INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sites',
)
The above is the bare minimum to run Django on GAE minus its admin.
I'm using the following main.py
in two different Django on GAE projects and they work fine:
import logging, os, sys
from google.appengine.dist import use_library
use_library('django', '1.1')
# Must set this env var *before* importing any part of Django
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
# Google App Engine imports.
from google.appengine.ext.webapp import util
# Remove the standard version of Django.
for k in [k for k in sys.modules if k.startswith('django')]:
del sys.modules[k]
# Force sys.path to have our own directory first, in case we want to import
# from it.
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
import django.core.handlers.wsgi
import django.db
def main():
# Create a Django application for WSGI.
application = django.core.handlers.wsgi.WSGIHandler()
# Run the WSGI CGI handler with that application.
util.run_wsgi_app(application)
if __name__ == '__main__':
main()
Upvotes: 0
Reputation: 599600
As others have noted, you can't use Django's ORM on AppEngine. However it's obvious that you are following some instructions to import django.db
in order to disconnect some signals. The error message shows you the problem: the sqlite3 library is not installed on your system.
Usually this comes along with Python versions 2.5 onwards, so you should have it as part of your 2.6 installation, but perhaps you have a minimal install for some reason. Try installing one of the full Python versions, from python.org or ActiveState, or you could try just installing the pysqlite2 library.
Upvotes: 2
Reputation: 2388
Why do you need django.db? How do you propose to use it? My guess is Django is searching for sqlite and it is not able to find it? Maybe if you install it the error would go.
Upvotes: 0