嘿,我是heroku和django的新手,我在按照这些教程时一直在解决问题: Tutorial 1 - django girl,Tutorial 2-heroku
我正在执行将现有项目部署到heroku的所有步骤,并且我不断收到此消息:
function contiguousnegatives() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("Sheet6");//change to sheet name needed
var lr = s.getLastRow()
var lc=s.getLastColumn()
for(var i=0;i<lr-1;i++){
var r = s.getRange(2, 1, lr-1, lc).getValues()//assumes a header row exists
count =0
totalneg=0
for(var j=0;j<lc;j++){
if(r[i][j]<0 && r[i][j+1]<0) //if two consecutive values are negative
{ count=count+1
}
if(r[i][j]<0){
var totalneg = totalneg+r[i][j] //totals all neg values in row
}}
if(count >0)
s.getRange(i+2, lc+2).setValue(totalneg)// set total of neg two col from end of row
}}
我的wsgi.py:
remote: $ python manage.py collectstatic --noinput
remote: Traceback (most recent call last):
remote: File "manage.py", line 9, in <module>
remote: execute_from_command_line(sys.argv)
remote: File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
remote: utility.execute()
remote: File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 302, in execute
remote: settings.INSTALLED_APPS
remote: File "/app/.heroku/python/lib/python3.4/site-packages/django/conf/__init__.py", line 55, in __getattr__
remote: self._setup(name)
remote: File "/app/.heroku/python/lib/python3.4/site-packages/django/conf/__init__.py", line 43, in _setup
remote: self._wrapped = Settings(settings_module)
remote: File "/app/.heroku/python/lib/python3.4/site-packages/django/conf/__init__.py", line 99, in __init__
remote: mod = importlib.import_module(self.SETTINGS_MODULE)
remote: File "/app/.heroku/python/lib/python3.4/importlib/__init__.py", line 104, in import_module
remote: return _bootstrap._gcd_import(name[level:], package, level)
remote: File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
remote: File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
remote: File "<frozen importlib._bootstrap>", line 2201, in _find_and_load_unlocked
remote: ImportError: No module named 'mysite.settings'
remote:
remote: ! Error while running '$ python manage.py collectstatic --noinput'.
remote: See traceback above for details.
remote:
remote: You may need to update application code to resolve this error.
remote: Or, you can disable collectstatic for this application:
remote:
remote: $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote: https://devcenter.heroku.com/articles/django-assets
remote:
remote: ! Push rejected, failed to compile Python app
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to mysitefp1.
remote:
To https://git.heroku.com/mysitefp1.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/mysitefp1.git'
我的procfile:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
my settings.py
"""
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 1.8.5.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '************************'
# SECURITY WARNING: don't run with debug turned on in production!
DJANGO_SETTINGS_MODULE="mysite.mysite.settings"
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'address',
'BusinessApp',
'BaseApp',
'UserApp',
'conversation',
'django_libs',
'widget_tweaks',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'mysite.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(PROJECT_ROOT, 'templates'), os.path.join(PROJECT_ROOT, 'templates', 'allauth')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_ROOT, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
"django.contrib.auth.backends.ModelBackend",
# `allauth` specific authentication methods, such as login by e-mail
"allauth.account.auth_backends.AuthenticationBackend"
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.request",
"django.contrib.auth.context_processors.auth",
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
)
# auth and allauth settings
LOGIN_REDIRECT_URL = '/'
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
SITE_ID=1
STATICFILES_DIRS = [
os.path.join(PROJECT_ROOT, 'static'),
# os.path.join(PROJECT_ROOT, 'media'),
# os.path.join(BASE_DIR, "static"),
# '/static/',
# '',
]
import dj_database_url
WSGI_APPLICATION = 'mysite.wsgi.application'
SOCIALACCOUNT_ADAPTER = 'BaseApp.adapters.ProfileAdapter'
ACCOUNT_USERNAME_REQUIRED = False
LOGIN_URL = "/"
DATABASES['default'] = dj_database_url.config()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ALLOWED_HOSTS = ['*']
DEBUG = False
try:
from .local_settings import *
except ImportError:
pass
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
# Update database configuration with $DATABASE_URL.
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
my requirements.txt:
web: gunicorn mysite.wsgi --log-file -
我无法弄清楚3天内发生了什么!请帮帮我
P.S如果我尝试禁用静态,当我尝试迁移时会再次发生同样的错误。
答案 0 :(得分:0)
我遇到了同样的问题,git不知何故没有将设置文件添加到我项目中的存储库中,我解决这个问题的方法是创建一个新的django项目和一个新的存储库,同时检查你是否将您的设置文件放在.gitignore文件中。如果您需要的所有内容都在那里,那么总是检查哪些更改将通过git状态提交,那么它应该可以正常工作。