Mezzanine4上で、
警告が
Mezzanine4の
環境情報
OS
CentOS release 6.7 (Final)Python Version
Python 2.7.8Package (必要そうな
ものだけ 抜粋)
Django (1.9.6)
Mezzanine (4.1.0)
前提
警告が
動作上は
plugin追加とかやる
Version3 Version4で ディレクトリ構造が 違う
- ディレクトリ構造
以下、コマンドで プロジェクト作成した 際の 構造が 違います。
Version4は、djangoの いつもの applicationの 構造に なっていました。
mezzanine-project myproject
Version3の
ディレクトリ構造(コマンドを 叩いたわけでないです。 自プロジェクト構造からの 推測) # プロジェクトディレクトリ直下 __init__.py deploy fabfile.py local_settings.py manage.py requirements.txt settings.py static urls.py wsgi.py # deployディレクトリ配下 crontab gunicorn.conf.py.template local_settings.py.template nginx.conf supervisor.conf
Version4の
ディレクトリ構造 Version3だと、# プロジェクトディレクトリ直下 __init__.py deploy fabfile.py manage.py myproject requirements.txt # deployディレクトリ配下 crontab.template gunicorn.conf.py.template local_settings.py.template nginx.conf.template supervisor.conf.template # myprojectディレクトリ配下 __init__.py local_settings.py settings.py urls.py wsgi.py
プロジェクト直下に 配布されていた local_settings.py,settings.py,urls.py,wsgi.py
が、
Verison4だと、1階層深くなり 配置されています。
ファイルごとの 差分 manage.py
Version4を
変更点は
from __future__ import absolute_import, unicode_literals
が削除されている。 real_project_name
という メソッドが 新規追加されている。 コメントが
削除され、 ファイルが 小さくなっている。 Version4の
manage.py
#!/usr/bin/env python import os import sys if __name__ == "__main__": from mezzanine.utils.conf import real_project_name settings_module = "%s.settings" % real_project_name("your_project_name") os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module) from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
ファイルごとの 差分 urls.py
ここは、
from django.views.i18n import set_language
が追加されている。 urlpatterns = i18n_patterns("",
の、("",
が削除されている。 urlpatterns += patterns('',
が、urlpatterns += [
に変更
RemovedInDjango110Warning
に
ファイルごとの 差分 settings.py
ここも、
変更点は
import os
の追加 from django import VERSION as DJANGO_VERSION
の追加 from django.utils.translation import ugettext_lazy as _
の追加 SECRET_KEY
が削除されている。 NEVERCACHE_KEY
が削除されている。 USE_MODELTRANSLATION = False
の追加 USE_SOUTH = True
が削除されている。 PROJECT_ROOTパス変数が
追加、 変更されている。 PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__)) PROJECT_APP = os.path.basename(PROJECT_APP_PATH) PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH)
PROJECT_DIRNAME
の削除 ROOT_URLCONF
のVALUE値の 変更 DEPLOY SETTINGS
のコメント部の 削除
################## # LOCAL SETTINGS # ################## f = os.path.join(PROJECT_APP_PATH, "local_settings.py") if os.path.exists(f): import sys import imp module_name = "%s.local_settings" % PROJECT_APP module = imp.new_module(module_name) module.__file__ = f sys.modules[module_name] = module exec(open(f, "rb").read())
ファイルごとの 差分 wsgi.py
これは
""" WSGI config for myproject project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application from mezzanine.utils.conf import real_project_name os.environ.setdefault("DJANGO_SETTINGS_MODULE", "%s.settings" % real_project_name("your_project_name")) application = get_wsgi_application()
ファイルごとの 差分 local_settings.py
これも
Version3よりも、
まるっと
# This file is exec'd from settings.py, so it has access to and can # modify all the variables in settings.py. # If this file is changed in development, the development server will # have to be manually restarted because changes will not be noticed # immediately. DEBUG = True # Make these unique, and don't share it with anybody. SECRET_KEY = "xxxxxxxx" NEVERCACHE_KEY = "xxxxxxxxx" DATABASES = { "default": { # Ends with "postgresql_psycopg2", "mysql", "sqlite3" or "oracle". "ENGINE": "django.db.backends.sqlite3", # DB name or path to database file if using sqlite3. "NAME": "dev.db", # Not used with sqlite3. "USER": "", # Not used with sqlite3. "PASSWORD": "", # Set to empty string for localhost. Not used with sqlite3. "HOST": "", # Set to empty string for default. Not used with sqlite3. "PORT": "", } } ################### # DEPLOY SETTINGS # ################### # Domains for public site # ALLOWED_HOSTS = [""] # These settings are used by the default fabfile.py provided. # Check fabfile.py for defaults. # FABRIC = { # "DEPLOY_TOOL": "rsync", # Deploy with "git", "hg", or "rsync" # "SSH_USER": "", # VPS SSH username # "HOSTS": [""], # The IP address of your VPS # "DOMAINS": ALLOWED_HOSTS, # Edit domains in ALLOWED_HOSTS # "REQUIREMENTS_PATH": "requirements.txt", # Project's pip requirements # "LOCALE": "en_US.UTF-8", # Should end with ".UTF-8" # "DB_PASS": "", # Live database password # "ADMIN_PASS": "", # Live admin user password # "SECRET_KEY": SECRET_KEY, # "NEVERCACHE_KEY": NEVERCACHE_KEY, # }
ファイル名称を 揃えて おく
Version3と
cd ${PROJECT_ROOT}/deploy mv crontab crontab.template mv nginx.conf nginx.conf.template mv supervisor.conf supervisor.conf.template
ファイル編集は
WSGIScriptAliasの 修正
Apacheを
以下の
[Sun May 08 01:23:27 2016] [error] [client xxx.xxx.xxx.xxx] Target WSGI script not found or unable to stat: ${プロジェクトルート}/wsgi.py
Apacheの
WSGIScriptAlias / ${プロジェクトルート}/wsgi.py process-group=blog application-group=%{GLOBAL}
Apacheを
以上です。
コメント