From 63330d7e7189976f60350a7ead650c061ce0c1a7 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 5 May 2020 15:27:38 +0200 Subject: [PATCH 06/10] misc: use NullBooleanField for BooleanField(null=True) with Django<2 (#42504) --- src/authentic2/migrations/0012_auto_20160211_2255.py | 4 ++-- src/authentic2/models.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git src/authentic2/migrations/0012_auto_20160211_2255.py src/authentic2/migrations/0012_auto_20160211_2255.py index 7d7f9d34..62a5b6c3 100644 --- src/authentic2/migrations/0012_auto_20160211_2255.py +++ src/authentic2/migrations/0012_auto_20160211_2255.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +import django from django.db import models, migrations @@ -14,7 +15,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='attributevalue', name='multiple', - field=models.BooleanField(default=False), - preserve_default=True, + field=models.NullBooleanField(default=False) if django.VERSION < (2,) else models.BooleanField(default=False, null=True), ), ] diff --git src/authentic2/models.py src/authentic2/models.py index a1c8e7a0..475cd9fc 100644 --- src/authentic2/models.py +++ src/authentic2/models.py @@ -18,6 +18,7 @@ import datetime import time import uuid +import django from django.utils.http import urlquote from django.conf import settings from django.db import models, transaction @@ -332,7 +333,10 @@ class AttributeValue(models.Model): 'Attribute', verbose_name=_('attribute'), on_delete=models.CASCADE) - multiple = models.BooleanField(default=False) + if django.VERSION < (2,): + multiple = models.NullBooleanField(default=False) + else: + multiple = models.BooleanField(default=False, null=True) content = models.TextField(verbose_name=_('content'), db_index=True) verified = models.BooleanField(default=False) -- 2.26.0