3

tornado サーバーで django アプリケーションを実行しています。

このスクリプトを使用すると:

#!/usr/bin/env python
#
# Runs a Tornado web server with a django project
# Make sure to edit the DJANGO_SETTINGS_MODULE to point to your settings.py
#
# http://localhost:8080/hello-tornado
# http://localhost:8080

import sys
import os

from tornado.options import options, define, parse_command_line
import tornado.httpserver
import tornado.ioloop
import tornado.web
import tornado.wsgi

from django.core.wsgi import get_wsgi_application


define('port', type=int, default=8080)


class HelloHandler(tornado.web.RequestHandler):
def get(self):
    self.write('Hello from tornado')


def main():
os.environ['DJANGO_SETTINGS_MODULE'] = 'siatpre.settings' # TODO: edit this
sys.path.append('./siatpre8') # path to your project if needed

parse_command_line()

wsgi_app = get_wsgi_application()
container = tornado.wsgi.WSGIContainer(wsgi_app)

tornado_app = tornado.web.Application(
    [
        ('/hello-tornado', HelloHandler),
        ('.*', tornado.web.FallbackHandler, dict(fallback=container)),
    ])

server = tornado.httpserver.HTTPServer(tornado_app)
server.listen(options.port)

tornado.ioloop.IOLoop.instance().start()

if __name__ == '__main__':
    main()

プロジェクト パス (siatpre8) は正しく、すべて正常に動作しています。唯一の問題は、管理スタイルの静的ファイルと、アプリにアップロードされたファイルです。

STATIC_ROOT, STATICFILES_DIRSただし、 settings.pyを配置した後でも、管理者スタイルを読み込めません。

これは開発環境ですが、アイデアはありますか?

詳細が必要な場合は、お知らせください。

前もって感謝します!

編集

私のディレクトリレイアウト:

├── ejemplosDeDatos
├── imagenes-aplicacion
├── node_modules
├── __pycache__
└── siatpre
├── apps
│   ├── __pycache__
│   └── scppp
│       ├── lector
│       │   └── __pycache__
│       ├── Prueba_presion
│       │   └── __pycache__
│       ├── __pycache__
│       └── Utilitarios
│           └── __pycache__
├── media
│   ├── archivosDeCarga
│   ├── css
│   ├── img
│   ├── js
│   │   └── jquery
│   │       ├── css
│   │       │   └── themes
│   │       │       └── base
│   │       │           └── images
│   │       └── js
│   ├── scppp
│   │   ├── imagenes-aplicacion
│   │   └── original
│   │       ├── css
│   │       ├── img
│   │       └── js
│   └── siatpre
│       └── scpp
├── __pycache__
├── static
│   ├── admin
│   │   ├── css
│   │   ├── img
│   │   │   └── gis
│   │   └── js
│   │       └── admin
│   ├── media
│   │   ├── archivosDeCarga
│   │   ├── css
│   │   ├── img
│   │   ├── js
│   │   ├── scppp
│   │   │   ├── imagenes-aplicacion
│   │   │   └── original
│   │   │       ├── css
│   │   │       ├── img
│   │   │       └── js
│   │   └── siatpre
│   │       └── scpp
│   └── templates
│       └── scppp
│           ├── imagenes-aplicacion
│           └── original
│               ├── css
│               ├── img
│               └── js
└── templates
    └── scppp
        ├── imagenes-aplicacion
        └── original
            ├── css
            ├── img
            └── js

私のsettings.py静的ファイル構造宣言:

STATIC_URL = '/static/'

#ADMIN_MEDIA_PREFIX = '/static/'

STATICFILES_DIRS = [
"home/kkoci/siatpre3.3.1/siatpre2015/siatpre8/siatpre/static/admin/",
"home/kkoci/siatpre3.3.1/siatpre2015/siatpre8/siatpre/media/archivosDeCarga/",
#"/home/polls.com/polls/static",
#"/opt/webfiles/common",
]
STATIC_ROOT = '/static/admin/'

#ADMIN_MEDIA_PREFIX = '/static/admin/css/'

STATICFILES_FINDERS = ( 
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__),'templates'),
)

MEDIA_ROOT =   os.path.normpath(os.path.join(os.path.dirname(__file__),'media/'))

MEDIA_URL = '/media/'
4

0 に答える 0