0

django-nonrel を Google App Engine で動作させることができました

唯一の問題は、私が管理者に入るときです。静的ファイルが表示されていないようです。

管理フォルダへのパスとファイル構造をここに示します

また、setuptools-1.1-py2.7.egg' は site-packages フォルダーにありますが、開けません。

djangoproject サイトの公式の Polls チュートリアルでこれをテストし始めました。

INFO     2013-09-01 09:25:52,707 dev_appserver_multiprocess.py:656] Running application dev~ctst on port 8000: http://127.0.0.1:8000
INFO     2013-09-01 09:25:52,709 dev_appserver_multiprocess.py:658] Admin console is available at: http://127.0.0.1:8000/_ah/admin
WARNING  2013-09-01 09:26:00,803 py_zipimport.py:139] Can't open zipfile C:\Python27\lib\site-packages\setuptools-1.1-py2.7.egg: IOError: [Errno 13] file not accessible: 'C:\\Python27\\lib\\site-packages\\setuptools-1.1-py2.7.egg'
INFO     2013-09-01 09:26:01,279 __init__.py:44] Validating models...
INFO     2013-09-01 09:26:01,562 __init__.py:55] All models validated.
INFO     2013-09-01 09:26:01,835 dev_appserver.py:3091] "GET /admin/ HTTP/1.1" 200 -
INFO     2013-09-01 09:26:02,000 dev_appserver.py:3091] "GET /admin/admin/css/base.css HTTP/1.1" 404 -
INFO     2013-09-01 09:26:02,319 dev_appserver.py:3091] "GET /admin/admin/css/login.css HTTP/1.1" 404 -

これが私のsettings.pyです

# Initialize App Engine and import the default settings (DB backend, etc.).
# If you want to use a different backend you have to remove all occurences
# of "djangoappengine" from this file.
from djangoappengine.settings_base import *

import os

# Activate django-dbindexer for the default database
DATABASES['native'] = DATABASES['default']
DATABASES['default'] = {'ENGINE': 'dbindexer', 'TARGET': 'native'}
AUTOLOAD_SITECONF = 'indexes'

SECRET_KEY = 'I have a secret key in my file but I can't show it here'

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.auth',
    'django.contrib.sessions',
    'djangotoolbox',
    'autoload',
    'dbindexer',

    # djangoappengine should come last, so it can override a few manage.py commands
    'djangoappengine',
    'polls',
)

    MIDDLEWARE_CLASSES = (
    # This loads the index definitions, so it has to come first
    'autoload.middleware.AutoloadMiddleware',

    'django.middleware.common.CommonMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.request',
    'django.core.context_processors.media',
)

# This test runner captures stdout and associates tracebacks with their
# corresponding output. Helps a lot with print-debugging.
TEST_RUNNER = 'djangotoolbox.test.CapturingTestSuiteRunner'

ADMIN_MEDIA_PREFIX = '/media/admin/'
TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)

ROOT_URLCONF = 'urls'

これは私の app.yaml ファイルです

application: ctst
version: 1
runtime: python27
api_version: 1
threadsafe: yes

builtins:
- remote_api: on

inbound_services:
- warmup

libraries:
- name: django
  version: latest

handlers:
- url: /_ah/queue/deferred
  script: djangoappengine.deferred.handler.application
  login: admin

- url: /_ah/stats/.*
  script: djangoappengine.appstats.application

- url: /media/admin
  static_dir: django/contrib/admin/media
  expiration: '0'

- url: /.*
  script: djangoappengine.main.application

私の urls.py ファイルを以下に示します。

from django.conf.urls.defaults import *
from django.contrib import admin

admin.autodiscover()

handler500 = 'djangotoolbox.errorviews.server_error'

urlpatterns = patterns('',
    (r'^admin/', include(admin.site.urls)),
    ('^_ah/warmup$', 'djangoappengine.views.warmup'),
    ('^$', 'django.views.generic.simple.direct_to_template',
     {'template': 'home.html'}),
)
4

1 に答える 1

0

私は同じ問題を抱えていて、次のように解決しました。

settings.py のインストール済みアプリ セクションに次の行を追加します。

'django.contrib.staticfiles',

私の静的 URL セクションの定義は次のとおりです (ADMIN_MEDIA_PREFIX は使用しません)。

STATIC_URL = '/static/'

最後に、app.yaml の /static/adimn URL ハンドラーは次のようになります。

- url: /static/admin
  static_dir: django/contrib/admin/static/admin/
  expiration: '0'

そして、djangononrelを使用しているため、アプリのyamlファイルでdjangoライブラリの定義を避ける必要があると思います。したがって、次の定義は必要ありません

libraries:
- name: django
  version: latest
于 2013-10-26T09:54:44.717 に答える