J'ai un projet Django 1.1.1 qui fonctionne bien. J'essaie de l'importer dans Google App Engine.Difficultés avec Django sur Google App Engine
Je suis en train de suivre ces instructions.
je l'exécute sur le serveur dev, et je reçois une erreur d'importation:
ImportError at/
No module named mysite.urls
C'est la structure du dossier de monsite/:
app.yaml
<DIR> myapp
index.yaml
main.py
manage.py
<DIR> media
settings.py
urls.py
__init__.py
app.yaml:
application: mysite
version: 1
runtime: python
api_version: 1
handlers:
- url: .*
script: main.py
de settings.py:
ROOT_URLCONF = 'mysite.urls'
Qu'est-ce que je fais mal?
MISE À JOUR:
maintenant je reçois cette erreur:
Request Method: GET
Request URL: http://localhost:8082/
Exception Type: AttributeError
Exception Value: 'module' object has no attribute 'autodiscover'
Exception Location: C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py in LoadModuleRestricted, line 1782
main.py:
import logging, os
# Google App Engine imports.
from google.appengine.ext.webapp import util
# Force Django to reload its settings.
from django.conf import settings
settings._target = None
# Must set this env var before importing any part of Django
# 'project' is the name of the project created with django-admin.py
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import logging
import django.core.handlers.wsgi
import django.core.signals
import django.db
import django.dispatch.dispatcher
def log_exception(*args, **kwds):
logging.exception('Exception in request:')
# Log errors.
django.dispatch.dispatcher.connect(
log_exception, django.core.signals.got_request_exception)
# Unregister the rollback event handler.
django.dispatch.dispatcher.disconnect(
django.db._rollback_on_exception,
django.core.signals.got_request_exception)
def main():
# Create a Django application for WSGI.
application = django.core.handlers.wsgi.WSGIHandler()
# Run the WSGI CGI handler with that application.
util.run_wsgi_app(application)
if __name__ == '__main__':
main()
structure Répertoire des engineapp/:
<DIR> mysite
app.yaml
index.yaml
main.py
structure Répertoire des engineapp/monsite:
<DIR> myapp
<DIR> media
__init__.py
initial_data.json
manage.py
settings.py
urls.py
Je sens que je me rapproche, mais toujours pas là.
ça a marché, mais j'ai encore plus de problèmes. (OP mis à jour.) –
Voir ma version modifiée maintenant. Bien que vous auriez peut-être dû fermer cette question et en ouvrir une nouvelle, puisque vous avez un problème différent maintenant. –