1

I'm trying to deploy my django-app to Google App Engine but keep getting this error when i run manage.py syncdb.

Traceback (most recent call last):


File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\__init__.py", line 69, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\utils\imp
ortlib.py", line 35, in import_module
    __import__(name)
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\commands\syncdb.py", line 8, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_
signal
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\core\mana
gement\sql.py", line 6, in <module>
    from django.db import models
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\db\__init
__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\db\__init
__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\db\utils.
py", line 92, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "C:\Program Files\Google\google_appengine\lib\django_1_4\django\db\utils.
py", line 44, in load_backend
    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'google.appengine.ext.django.backen
ds.rdbms' isn't an available database backend.
Try using django.db.backends.XXX, where XXX is one of:
    'dummy', 'mysql', 'oracle', 'postgresql_psycopg2', 'rdbms', 'sqlite3'
Error was: No module named django.backends.rdbms.base

I've made sure that these are included in my pythonpath:-

C:\ProgramFiles\Google\google_appengine;C:\ProgramFiles\Google\google_appengine\lib\django_1_4

yet I still get the No modules named django.backends.rdbms.base.

here's my settings.py

# Django settings for firstproject project.

import os
BASE_DIR = os.path.abspath(os.path.dirname(__file__)) + os.sep

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

#production =  True

import os

SETTINGS_MODE='prod'

if (os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine') or
    os.getenv('SETTINGS_MODE') == 'prod'):

    DATABASES = {
    'default': {
        'ENGINE': 'google.appengine.ext.django.backends.rdbms',
        'INSTANCE': 'd73292536:instance1',
        'NAME': 'example',
    }
}

else:

        DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
            'NAME': 'third',                      # Or path to database file if using sqlite3.
            'USER': 'root',                      # Not used with sqlite3.
            'PASSWORD': '',                  # Not used with sqlite3.
            'HOST': '127.0.0.1',                      # Set to empty string for localhost. Not used with sqlite3.
            'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
        }
    }

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Eastern'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '' 

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative path
    "C:\Users\sheila\Desktop\Templates\static",
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '+iiq+84-xm_pmxsbwz18#*n2hht$5f9o_m6d8spt2buhxxl0m='

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'google.appengine.ext.ndb.django_middleware.NdbDjangoMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'firstproject.wsgi.application'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.

    "C:\\Users\\sheila\\Desktop\\Templates\\polls"
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    #'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'polls',
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}
Wooble
  • 87,717
  • 12
  • 108
  • 131
  • 1
    Hang on, is this when running locally or when you deploy? You seem to contradict yourself. – Daniel Roseman Jan 23 '13 at 17:24
  • It works well when it is running locally. when I try to deploy, I get the above error. – IamKing Luke Jan 23 '13 at 17:35
  • is it a pure django app (ie, without any direct invocation of GAE's API)? – Marco L. Jan 23 '13 at 18:38
  • yes, it's pure django. I'm trying to use this page - https://developers.google.com/appengine/docs/python/cloud-sql/django - to deploy my app. – IamKing Luke Jan 23 '13 at 18:50
  • 2
    Sorry that still makes no sense. You're running `manage.py` locally, and I can see `C:/` paths in the traceback. So what does this have to do with deploying? – Daniel Roseman Jan 23 '13 at 19:33
  • I've been running locally during the development stage. I run manage.py runserver and go to 127.0.0.1:8000 to see the progress . I'm now trying deploy my app to app engine by running manage.py syncdb with the database settings given by app engine, and I get the above error. I changed my engine to google.appengine.ext.django.backends.rdbms, changed my instance to the correct instance, and gave the database name. Any ideas? – IamKing Luke Jan 23 '13 at 19:43
  • It might help if you showed the contents of your settings.py, especially the DATABASES setting. – dragonx Jan 23 '13 at 21:47
  • ok, i added my settings. – IamKing Luke Jan 24 '13 at 05:14

4 Answers4

0

I believe that's provided for you, you don't have to add in the files, see here:3rd party libraries

Do you have this in your app.yaml?

libraries:
- name: django
  version: "1.4"

Also this may be relevant:

To use Django with the NDB storage API, add 'google.appengine.ext.ndb.django_middleware.NdbDjangoMiddleware', to the MIDDLEWARE_CLASSES entry in your Django settings.py file.

Same link as above.

Paul Collingwood
  • 9,053
  • 3
  • 23
  • 36
0

One issue is that, your setting file is wrong. It seems like in your settings file, you set
'ENGINE': 'google.appengine.ext.django.backends.rdbms' . import os if (os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine') or     os.getenv('SETTINGS_MODE') == 'prod'):

Emmet B
  • 5,341
  • 6
  • 34
  • 47
  • Are you sure? This page seems to suggest they do. https://developers.google.com/appengine/docs/python/cloud-sql/django – IamKing Luke Jan 23 '13 at 18:31
  • What's your settings file? Did you add those
    import os if (os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine') or     os.getenv('SETTINGS_MODE') == 'prod'):
    – Emmet B Jan 23 '13 at 19:42
  • Actually, you're right. That was the problem. I had them on but they were reversed. Thanks. – IamKing Luke Jan 23 '13 at 19:58
0

Possible duplicate of my question. See the accepted answer and the linked follow-up question for more info on deployment.

I eventually got deployment sorted by using the suggested if: else: clause in SETTINGS.PY for the database definitions.

Community
  • 1
  • 1
Roger
  • 4,737
  • 4
  • 43
  • 68
0

In your question, you mentioned you added the following to your PYTHONPATH

C:\ProgramFiles\Google\google_appengine;C:\ProgramFiles\Google\google_appengine\lib\django_1_4

That path is wrong, since there is a space in "Program Files". Hence your runtime isn't finding google.appengine.ext.django.backends.rdbms.

dragonx
  • 14,963
  • 27
  • 44
  • I had the spaces on there. I don't know why I removed them when posting the question. But i think the problem has to do with pythonpath. On googles website, https://developers.google.com/appengine/docs/python/cloud-sql/django , we are supposed to do this:- export PYTHONPATH="$PYTHONPATH:/home/user/google_appengine:/home/user/google_appengine/lib/django_1_3" Am I doing it right with the pythonpath? – IamKing Luke Jan 24 '13 at 06:03
  • You're right, that's a Linux command. http://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7 – dragonx Jan 24 '13 at 06:06