出力される警告

django-request のインストール中に以下の警告が出力される。

  • コマンド

    python manage.py makemigrations request
    

  • OUTPUT
    mezzanine.core.W01いうのは、mezzanineのwarningということかもしれません。

WARNINGS:
?: (mezzanine.core.W01) Please update your settings to use the TEMPLATES setting rather than the deprecated individual TEMPLATE_ settings. The latter are unsupported and correct behaviour is not guaranteed. Here's a suggestion based on on your existing configuration:

  • 追記 そもそも、警告がたくさん出力されるのは、
    Mezzanine4上で、Mezzanine3系のsettings.py等を使用しているからっぽいので、
    後日こちらでまとめて対処しました。

対応方法

~~Django 1.8から、settings.pyのTEMPLATESが非推奨になったようなので、 ~~ Django 1.8から、settings.pyのTEMPLATES_xxxで記載していた設定が、廃止になったようなので、
settings.pyの内容を修正します。
いうか警告メッセージ下部にご丁寧にこう修正してねが出力されます!

TEMPLATES = [{u'APP_DIRS': True,
              u'BACKEND': u'django.template.backends.django.DjangoTemplates',
              u'DIRS': (u'YOUR_TEMPLATE_DIR',),
              u'OPTIONS': {u'builtins': [u'mezzanine.template.loader_tags'],
                           u'context_processors': (u'django.contrib.auth.context_processors.auth',
                                                   u'django.contrib.messages.context_processors.messages',
                                                   u'django.core.context_processors.debug',
                                                   u'django.core.context_processors.i18n',
                                                   u'django.core.context_processors.static',
                                                   u'django.core.context_processors.media',
                                                   u'django.core.context_processors.request',
                                                   u'django.core.context_processors.tz',
                                                   u'mezzanine.conf.context_processors.settings',
                                                   u'mezzanine.pages.context_processors.page')}}]

  • settings.pyに上記記述を追加
    # List of callables that know how to import templates from various sources.
    #TEMPLATE_LOADERS = (
    #    "django.template.loaders.filesystem.Loader",
    #    "django.template.loaders.app_directories.Loader",
    #)
    TEMPLATES = [{u'APP_DIRS': True,
                  u'BACKEND': u'django.template.backends.django.DjangoTemplates',
                  u'DIRS': (u'YOUR_TEMPLATE_DIR',),
                  u'OPTIONS': {u'builtins': [u'mezzanine.template.loader_tags'],
                               u'context_processors': (u'django.contrib.auth.context_processors.auth',
                                                       u'django.contrib.messages.context_processors.messages',
                                                       u'django.core.context_processors.debug',
                                                       u'django.core.context_processors.i18n',
                                                       u'django.core.context_processors.static',
                                                       u'django.core.context_processors.media',
                                                       u'django.core.context_processors.request',
                                                       u'django.core.context_processors.tz',
                                                       u'mezzanine.conf.context_processors.settings',
                                                       u'mezzanine.pages.context_processors.page')}}]
    
  • 再度コマンドを実行

    python manage.py makemigrations request
    

  • OUTPUT
    まだ、警告が出力されます。
    デフォルトで使っていた
    TEMPLATE_DIRS, TEMPLATE_CONTEXT_PROCESSORSを
    TEMPLATESに追加しなさいということでしょうか..

WARNINGS:
?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS, TEMPLATE_CONTEXT_PROCESSORS.

  • TEMPLATE_DIRS,TEMPLATE_CONTEXT_PROCESSORSそのままになっていたので、コメントアウト
    DjangoかMezzanineが出力してくている、
    u'DIRS': (u'YOUR_TEMPLATE_DIR',),は、
    os.path.join(PROJECT_ROOT, “templates”)が展開されてパスが出力されているようです。

# Put strings here, like "/home/html/django_templates"
# or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
#TEMPLATE_DIRS = (
#    os.path.join(PROJECT_ROOT, "templates"),)

# List of processors used by RequestContext to populate the context.
# Each one should be a callable that takes the request object as its
# only parameter and returns a dictionary to add to the context.
#TEMPLATE_CONTEXT_PROCESSORS = (
#    "django.contrib.auth.context_processors.auth",
#    "django.contrib.messages.context_processors.messages",
#    "django.core.context_processors.debug",
#    "django.core.context_processors.i18n",
#    "django.core.context_processors.static",
#    "django.core.context_processors.media",
#    "django.core.context_processors.request",
#    "django.core.context_processors.tz",
#    "mezzanine.conf.context_processors.settings",
#    "mezzanine.pages.context_processors.page",
#)

  • 再度コマンドを実行
    警告が消えたことを確認しました。

python manage.py makemigrations request

以上です。

コメント