[Django] #26168: Django forcibly allow BooleanField blank

22 views
Skip to first unread message

Django

unread,
Feb 3, 2016, 3:16:36 AM2/3/16
to django-...@googlegroups.com
#26168: Django forcibly allow BooleanField blank
----------------------------------------------+--------------------------
Reporter: fengyehong | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords: BooleanField
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------------
https://github.com/django/django/tree/master/django/db/models/fields#L1017

{{{
def __init__(self, *args, **kwargs):
kwargs['blank'] = True
super(BooleanField, self).__init__(*args, **kwargs)
}}}

blank is set to True forcibly

I want my BooleanField always explicitly set(without a default value),
like this:

{{{
myflag = models.BooleanField(blank=False)
}}}

but with this `kwargs['blank'] =True`, Django does not complain if field
`myflag` not set, but try to use default of BooleanField(in 1.7.5, None)
which lead to exception when saving~

I think force blank = True makes sense for NullBooleanField, but for
BooleanField, we can leave it to user.

Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/26168>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 3, 2016, 7:43:06 AM2/3/16
to django-...@googlegroups.com
#26168: BooleanField is forced to be blank=True
-------------------------------------+-------------------------------------
Reporter: fengyehong | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: BooleanField | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

See #22282 and #23130 for some related discussion. I'm not sure what the
proper resolution is, but I'll accept the ticket since this this has come
up several time. We can at least document the reasons for this if it can't
be changed for backwards compatibility reasons.

--
Ticket URL: <https://code.djangoproject.com/ticket/26168#comment:1>

Django

unread,
Feb 10, 2016, 1:10:16 PM2/10/16
to django-...@googlegroups.com
#26168: BooleanField is forced to be blank=True
-------------------------------------+-------------------------------------
Reporter: fengyehong | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: BooleanField | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by jonashaag):

There's an outdated patch in #23130, which I still think is the best
solution to this problem. Somehow, I've never gotten around to finishing
the patch, but I think it should take no more than an hour of time to get
it up to date and pass the test suite.

--
Ticket URL: <https://code.djangoproject.com/ticket/26168#comment:2>

Django

unread,
Feb 10, 2016, 1:10:33 PM2/10/16
to django-...@googlegroups.com
#26168: BooleanField is forced to be blank=True
-------------------------------------+-------------------------------------
Reporter: fengyehong | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: BooleanField | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jonashaag):

* cc: jonas@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/26168#comment:3>

Django

unread,
Feb 23, 2016, 9:43:03 AM2/23/16
to django-...@googlegroups.com
#26168: BooleanField is forced to be blank=True
-------------------------------------+-------------------------------------
Reporter: fengyehong | Owner:
Type: | insomniac12
Cleanup/optimization | Status: assigned

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: BooleanField | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by insomniac12):

* status: new => assigned
* owner: nobody => insomniac12


--
Ticket URL: <https://code.djangoproject.com/ticket/26168#comment:4>

Django

unread,
Sep 3, 2017, 6:58:14 AM9/3/17
to django-...@googlegroups.com
#26168: BooleanField is forced to be blank=True
-------------------------------------+-------------------------------------
Reporter: fengyehong | Owner: Lynn
Type: | Cyrin

Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: BooleanField | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Lynn Cyrin):

* status: new => assigned

* owner: nobody => Lynn Cyrin


Comment:

The WIP PR https://github.com/django/django/pull/9016 I made for
https://code.djangoproject.com/ticket/23130 addresses this

Django

unread,
Jul 7, 2018, 5:46:42 PM7/7/18
to django-...@googlegroups.com
#26168: BooleanField is forced to be blank=True
-------------------------------------+-------------------------------------
Reporter: fengyehong | Owner: Lynn
Type: | Cyrin
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: BooleanField | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kamil Gałuszka):

* cc: Kamil Gałuszka (added)


Comment:

I think this was fixed with https://github.com/django/django/pull/8467 and
#29227 . This ticket can be close then?

--
Ticket URL: <https://code.djangoproject.com/ticket/26168#comment:5>

Django

unread,
Jul 9, 2018, 10:32:23 AM7/9/18
to django-...@googlegroups.com
#26168: BooleanField is forced to be blank=True
-------------------------------------+-------------------------------------
Reporter: fengyehong | Owner: Lynn
Type: | Cyrin
Cleanup/optimization | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: BooleanField | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: assigned => closed
* resolution: => fixed


--
Ticket URL: <https://code.djangoproject.com/ticket/26168#comment:6>

Reply all
Reply to author
Forward
0 new messages