0

我将 python 2.7 与PostgreSQL一起使用,并按照此处文档中的说明配置了数据库设置,当我尝试部署到 heroku 时,我得到了这个

2012-08-02T10:33:41+00:00 heroku[web.1]: Starting process with command `python ./manage.py runserver 0.0.0.0:53271 --noreload`
2012-08-02T10:33:42+00:00 app[web.1]: Traceback (most recent call last):
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
2012-08-02
T10:33:42+00:00 app[web.1]:   File "./manage.py", line 10, in <module>
2012-08-02T10:33:42+00:00 app[web.1]:     execute_from_command_line(sys.argv)
2012-08-02T10:33:42+00:00 app[web.1]:     utility.execute()
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
2012-08-02T10:33:42+00:00 app[web.1]:     self.fetch_command(subcommand).run_from_argv(self.argv)
2012-08-02T10:33:42+00:00 app[web.1]:     self.execute(*args, **options.__dict__)
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 217, in execute
2012-08-02T10:33:42+00:00 app[web.1]:     translation.activate('en-us')
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 105, in activate
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 194, in activate
2012-08-02T10:33:42+00:00 app[web.1]:     return _trans.activate(language)
2012-08-02T10:33:42+00:00 app[web.1]:     _active.value = translation(language)
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 183, in translation
2012-08-02T10:33:42+00:00 app[web.1]:     default_translation = _fetch(settings.LANGUAGE_CODE)
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 160, in _fetch
2012-08-02T10:33:42+00:00 app[web.1]:     app = import_module(appname)
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
2012-08-02T10:33:42+00:00 app[web.1]:     __import__(name)
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 3, in <module>
2012-08-02T10:33:42+00:00 app[web.1]:     from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/helpers.py", line 2, in <module>
2012-08-02T10:33:42+00:00 app[web.1]:     from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/util.py", line 1, in <module>
2012-08-02T10:33:42+00:00 app[web.1]:     from django.db import models
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module>
2012-08-02T10:33:42+00:00 app[web.1]:     backend = load_backend(connection.settings_dict['ENGINE'])
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
2012-08-02T10:33:42+00:00 app[web.1]:     return getattr(connections[DEFAULT_DB_ALIAS], item)
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/utils.py", line 92, in __getitem__
2012-08-02T10:33:42+00:00 app[web.1]:     backend = load_backend(db['ENGINE'])
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/utils.py", line 24, in load_backend
2012-08-02T10:33:42+00:00 app[web.1]:     return import_module('.base', backend_name)
2012-08-02T10:33:42+00:00 app[web.1]:     __import__(name)
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 31, in <module>
2012-08-02T10:33:42+00:00 app[web.1]:   File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
2012-08-02T10:33:42+00:00 app[web.1]:     raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
2012-08-02T10:33:42+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3

这就是我的 settings.py 的样子

# Django settings for WEB project.
import os
import dj_database_url

PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__))

DEBUG = True
TEMPLATE_DEBUG = DEBUG
#####################################Django-Social auth
FACEBOOK_APP_ID = 'xxxxxxxxxxxxxxxx'
FACEBOOK_API_SECRET = 'xxxxxxxxxxxxxxxxxxxxx'

TWITTER_CONSUMER_KEY = 'xxxxxxxxxxxxxxxxxxxxx'
TWITTER_CONSUMER_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'


FACEBOOK_EXTENDED_PERMISSIONS = ['email','user_birthday','user_location']

FACEBOOK_EXTRA_DATA = [
    ('user_location', 'location')
]

SOCIAL_AUTH_CREATE_USERS = True

SOCIAL_AUTH_ASSOCIATE_BY_MAIL = False

SOCIAL_AUTH_USER_MODEL = 'shoghlanah.Employer'

SOCIAL_AUTH_RAISE_EXCEPTIONS = False

SOCIAL_AUTH_BACKEND_ERROR_URL = '/login/'

# LOGIN_URL          = '/login-form/'
LOGIN_REDIRECT_URL = '/home/'
#LOGIN_ERROR_URL    = '/login/'

# SOCIAL_AUTH_COMPLETE_URL_NAME  = 'socialauth_complete'
# SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'socialauth_associate_complete'

# SOCIAL_AUTH_DEFAULT_USERNAME = 'new_social_auth_user'

#SOCIAL_AUTH_USER_MODEL = 'shoghlanah.Employer'

#SOCIAL_AUTH_ASSOCIATE_BY_MAIL = False
########################################

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'shoghlanah.megasoft@gmail.com'
EMAIL_HOST_PASSWORD = 'megasoft'
EMAIL_PORT = 587

AUTHENTICATION_BACKENDS = ('shoghlanah.backends.EmailBackend',
    'django.contrib.auth.backends.ModelBackend',
)
ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.postgresql_psycopg2' , #'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
#         'NAME': 'shoghlanahDB',                  # Or path to database file if using sqlite3.
#         'USER': 'postgres',                      # Not used with sqlite3. #postgres
#         'PASSWORD': 'password',                  # Not used with sqlite3. #password
#         'HOST': '',                     # Set to empty string for localhost. Not used with sqlite3.
#         'PORT': '5432',                      # Set to empty string for default. Not used with sqlite3. #5432

#     }
# }

# 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.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Egypt'

# 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 = os.path.join( os.path.dirname( __file__ ), 'Uploads')
MEDIA_ROOT = os.path.join(PACKAGE_ROOT, "site_media", "media")

# 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 = '/Uploads/'
MEDIA_URL = "/site_media/media/"

# 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 = ''
STATIC_ROOT = os.path.join(PACKAGE_ROOT, "site_media", "static")

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

# Additional locations of static files
STATICFILES_DIRS = (
    os.path.join( os.path.dirname( __file__ ), 'static' ),
    # 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 paths.
)


# 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 = '2814zs+o5j!j)8fvmke!0y&amp;vj%hub#(w!35th_)y(*+x*g(_zm'

# 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 = (
    '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 = 'WEB.urls'

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

TEMPLATE_DIRS = (
    os.path.join( os.path.dirname( __file__ ), 'templates' ),
    #os.path.join( os.path.dirname( __file__ ), 'Uploads' ),
    # 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.
)
#  Provide.our getProfile()
#DJANGO_SETTINGS_MODULE='WEB.settings_gondor'
AUTH_PROFILE_MODULE='shoghlanah.Employer'
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'shoghlanah',
    #'social_auth', #########################################Django-social-auth
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    #'twitter_users'
    # Uncomment the next line to enable admin documentation:
    'django.contrib.admindocs',
    'oembed_works',
    #'south',
)

#################################################Django-Scoial-auth
AUTHENTICATION_BACKENDS = (
   'social_auth.backends.facebook.FacebookBackend',
   'social_auth.backends.twitter.TwitterBackend',
   'django.contrib.auth.backends.ModelBackend'
   #'twitter_users.backends.TwitterBackend'
)

SOCIAL_AUTH_ENABLED_BACKENDS = ('facebook','twitter'
)

EASY_MAPS_GOOGLE_KEY ='AIzaSyDLWxu_BdiJK24W46KhlSORMJT0_ZcK8IU'


TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    "django.core.context_processors.tz",
    "django.contrib.messages.context_processors.messages",
    'social_auth.context_processors.social_auth_by_type_backends',
    'social_auth.context_processors.social_auth_by_name_backends',
   'social_auth.context_processors.social_auth_backends',
   'social_auth.context_processors.social_auth_by_type_backends',
   "django.core.context_processors.request",
)
##################################################

# 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,
        },
    }
}
PASSWORD_HASHERS = (
    'django.contrib.auth.hashers.PBKDF2PasswordHasher',
    'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
    'django.contrib.auth.hashers.BCryptPasswordHasher',
    'django.contrib.auth.hashers.SHA1PasswordHasher',
    'django.contrib.auth.hashers.MD5PasswordHasher',
    'django.contrib.auth.hashers.CryptPasswordHasher',
)

而且我没有配置sqlite3,顺便说一下,我第一次部署时我没有遇到这个问题,后来我明白了,感谢任何hep

更新 1 requirements.txt

Django==1.4
PIL==1.1.7
South==0.7.5
dj-database-url==0.2.1
django-oembed-works==0.2.2
django-social-auth==0.7.0
django-stdimage==0.2.2
gondor==1.1.3
gunicorn==0.14.5
httplib2==0.7.4
oauth2==1.5.211
psycopg2==2.4.5
python-openid==2.2.5
wsgiref==0.1.2
4

0 回答 0