2011-02-25 5 views
3

장고를 사용하는 방법을 배우고 있으며 Google App Engine을 사용하고 있습니다. 내 메인과 같은 디렉토리에 최신 Django 디렉토리가 있습니다.Django + GoogleAppEngine 오류 : DJANGO_SETTINGS_MODULE이 정의되지 않았습니다.

내 로컬에서 실행하면 정상적으로 작동합니다. 하지만 웹 페이지에서 배포하고 실행하면 서버 오류가 발생합니다. 여기

은 내 main.py에 대한 코드와 settings.py

main.py입니다 :

import os 
import settings 
from django.template import Context, Template 
from google.appengine.ext import webapp 
from google.appengine.ext.webapp.util import run_wsgi_app 

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' 

class MainPage(webapp.RequestHandler): 
    def get(self): 
     self.response.headers['Content-Type'] = 'text/plain' 
     self.response.out.write('Hello, World!\n') 
     t = Template('It is now {% now "jS F Y H:i" %}') 
     c = Context({ }) 
     self.response.out.write(t.render(c)) 

application = webapp.WSGIApplication(
            [('/', MainPage)], 
            debug=True) 

def main(): 
    run_wsgi_app(application) 

if __name__ == "__main__": 
    main() 

settings.py :

import os 

DEBUG = True 
TEMPLATE_DEBUG = DEBUG 
TIME_ZONE = 'America/Whitehorse' 
LANGUAGE_CODE = 'en-us' 
SITE_ID = 1 
+0

memcache가 플러시 될 때마다이 오류가 발생합니다. – abel

답변

2

당신은 문제가있는 경우 환경 변수를 설정 한 다음 직접 설정을 구성하십시오 (http://docs.djangoproject.com/en/dev/topics/settings/#using-settings-without-setting-django-settings-module 참조)

import settings 
import django.conf 

# Filter out all the non-setting attributes of the settings module 
settingsKeys = filter(lambda name: str(name) == str(name).upper(), 
         dir(settings)) 

# copy all the setting values from the settings module into a dictionary 
settingsDict = dict(map(lambda name: (name, getattr(settings, name)), 
         settingsKeys)) 

django.conf.settings.configure(**settingsDict) 
관련 문제