2014-07-19 3 views
0

장고로 만든 웹 사이트를 이미 끝 냈고 설치하고 싶습니다. 나는 Heroku를 발견했고, 그것이 나의 기본적인 필요를 위해 자유롭고, 그것을 호스트하고 싶어했다. 내 사이트는 PostgreSQL이 아닌 SQLite를 사용하므로 sqlite를 지원하지 않으므로 사용법을 알고 싶습니다. Heroku에서 Django 페이지를 시작하는 것을 발견했지만 pip 또는 virtualenv를 사용하지 않았습니다.Heroku와 이미 만든 Django 웹 사이트를 호스팅합니다.

사이트를 개선하려면 어떤 단계를 따라야합니까? 필자는 최신 Django dev 브랜치 1.8과 Python 3.4.1을 사용하고 있으며 개인 웹 사이트입니다. Heroku가이 파일을 당신이 필요로하는 서비스를 제공하는 것을 사용하기 때문에

여기, 당신은 모든 의존성을 가진 requirements.txt 필요 내 settings.py 파일

""" 
Django settings for mysite project. 

For more information on this file, see 
https://docs.djangoproject.com/en/dev/topics/settings/ 

For the full list of settings and their values, see 
https://docs.djangoproject.com/en/dev/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__)) 


# Quick-start development settings - unsuitable for production 
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/ 

# SECURITY WARNING: keep the secret key used in production secret! 
SECRET_KEY = '0r58%!j00w2q1faj*57=d)*fv^=ai#-wgnakj91^--z5f(ohq1' 

# SECURITY WARNING: don't run with debug turned on in production! 
DEBUG = True 

TEMPLATE_DEBUG = True 

ALLOWED_HOSTS = [] 


# Application definition 

INSTALLED_APPS = (
    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
) 

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', 
) 

ROOT_URLCONF = 'mysite.urls' 

WSGI_APPLICATION = 'mysite.wsgi.application' 


# Database 
# https://docs.djangoproject.com/en/dev/ref/settings/#databases 

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.sqlite3', 
     'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 
    } 
} 

# Internationalization 
# https://docs.djangoproject.com/en/dev/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/dev/howto/static-files/ 

STATIC_URL = '/static/' 

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(BASE_DIR), "static", "templates"), 
    ) 

if DEBUG: 
    MEDIA_URL = '/media/' 
    STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "static-only") 
    MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "media") 
    STATICFILES_DIRS = (
     os.path.join(os.path.dirname(BASE_DIR), "static", "static"), 
     ) 

답변

0

입니다.

heroku 프로젝트에 postgreSQL 애드온을 추가하면 heroku가 DATABASE_URL 환경 변수를 생성합니다. 당신에게 Heroku의 튜토리얼에 따라 settings.py에 그것을 구문 분석 할 수 있습니다 : 기본 wsgi.py은 또한 튜토리얼에서 제공되는

# Parse database configuration from $DATABASE_URL 
import dj_database_url 
DATABASES['default'] = dj_database_url.config() 

, 당신은 그냥 사용할 수 있습니다.

from django.core.wsgi import get_wsgi_application 
from dj_static import Cling 

application = Cling(get_wsgi_application()) 

로컬 git 저장소에 응용 프로그램을 커밋하고 heroku 원격 저장소로 푸시합니다. 콘솔에서 그렇게하면 배포에 대한 좋은 의견을 얻을 수 있습니다.

기본적으로 사용자는 getting started tutorial을 따라야합니다. 가상 환경을 생략하면 요구 사항 파일을보다 복잡하게 생성 할 수 있지만 가능합니다.

관련 문제