使用している Django Version

使用 Version は 1.10 です。

pip list
----------------------------
Django (1.10)
----------------------------


内容

Django BooleanFiled に Null を設定しようとして、以下のような記述をしたのですが、

class FestivalArtistTagTmp(models.Model):

    is_parent = models.BooleanField(null=True)

(fields.E110) BooleanFields do not accept null values.
いうエラーが発生しました。

python3 manage.py makemigrations

-------------------------------

SystemCheckError: System check identified some issues:

ERRORS:
festivals4partypeople.FestivalArtistTagTmp.is_parent: (fields.E110) BooleanFields do not accept null values.
        HINT: Use a NullBooleanField instead.

-------------------------------


対応方法

以下の記事を見つけました。
Not using NullBooleanField — Python Anti-Patterns documentation

エラーメッセージにも出力されていますが、
NullBooleanField を使いなさいということなので、
以下の通りコードを書き換えました。

class FestivalArtistTagTmp(models.Model):

    is_parent = models.NullBooleanField(null=True)

以上です。

コメント