所以,我写这篇文章的时候需要注意的是,我很清楚你会要求提供更多信息,但我还不知道该放什么。
我有一个django-app正在为一个个人网站提供支持,该网站有一个简单的留言板供人们留下关于我是多么棒的留言。现在,我在使用这个应用程序时遇到了很多麻烦,并且经常出现很多问题,这就是我猜测可能会以某种方式导致这个问题。
不知何故,我的数据不断被我的数据库的特定快照所取代。当我今天早上检查它时,它有十个旧的虚拟测试消息和一个新的真实测试消息。我回复了新的真实的,删除了虚拟测试,一切看起来都很好。那天我没有再次触摸应用程序。当我刚才再次检查时,新消息消失了,虚拟消息又回来了。
它是通过Heroku部署的,用Python 2.7和Django 1.6编写。该网站现已在www.wienerwedding.com/guestbook/上发布。
这是我的settings.py文件,这是我可以对可能存在的问题做出的唯一猜测。 如果你告诉我看看会有什么帮助,我会把它包括在内。
# Django settings for wedding project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('xxx', 'xxxx@gmail.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'wedding.db',
}
}
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['*']
# Parse database configuration from $DATABASE_URL
if(DEBUG != True):
import dj_database_url
DATABASES['default'] = dj_database_url.config()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
TIME_ZONE = 'America/New_York'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
MEDIA_ROOT = '/Users/paulnichols/code/wedding/mainsite/static/images/photoalbum/'
MEDIA_URL = 'http://127.0.0.1:8000/photos/'
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'mainsite/static/'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'staticfiles'),
)
# 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 = 'xxxxxxxx'
# 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',
'django_user_agents.middleware.UserAgentMiddleware',
)
ROOT_URLCONF = 'wedding.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'wedding.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.
'mainsite/templates',
'quiz/templates',
'photoalbum/templates',
)
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',
'mainsite',
'quiz',
'photoalbum',
'django_google_maps',
'django_user_agents',
'south',
)
# 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,
},
}
}
答案 0 :(得分:0)
您将DEBUG设置为True,根据该代码意味着您将始终使用sqlite db文件,该文件可能与您的应用程序一起上传,而不是Heroku的Postgres设置。确保DEBUG为false,和/或使用其他环境变量来确定是否使用开发db。