タグ: pip

  • Django on vagrant の環境構築の補足 – Python3

    pyvenv の pip を更新(9.0.1)して、
    $ pip list
    とすると、

    DEPRECATION: The default format will switch to columns in the future. You can use –format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.

    という警告が表示されたので、
    https://pip.pypa.io/en/stable/user_guide/#configuration
    こちらを参考に、
    (pyvenv)/pip.conf
    を作成。

    [list]
    format=columns

    次に、開発用の簡易Webサーバを起動して、ブラウザで開くと、

    DisallowedHost at / …

    のような警告が表示されたので、
    https://docs.djangoproject.com/en/1.10/topics/settings/
    こちらを参考に、
    (project)/settings.pyを編集して、

    ALLOWED_HOSTS = [ '192.168.33.xx' ]

    を追加。

    追記(2016/12/12)
    モデル定義を編集してmigrateしたところでWARINGSが表示された。

    WARNINGS:
    ?: (mysql.W002) MySQL Strict Mode is not set for database connection ‘default’
    HINT: MySQL’s Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/1.10/ref/databases/#mysql-sql-mode

    https://docs.djangoproject.com/en/1.10/ref/databases/#mysql-sql-mode
    http://django-mysql.readthedocs.io/en/latest/checks.html#django-mysql-w001-strict-mode
    このあたりを読んで、settings.pyのDATABASESにオプションを追加。

    'OPTIONS': {
        'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
    },