Bleach is a Python module that takes any HTML input, and returns valid, sanitised HTML that contains only an allowed subset of HTML tags, attributes and styles. django-bleach is a Django app that makes using bleach extremely easy.
MIT License
148
stars
23
forks
source link
Model formfield() does not honor model field blank attribute making form field always required #21
Recently it was changed to return BleachField which inherently does not call super() where base Field correctly interprets other django model field attributes such as blank:
Describe the bug
When
blank=True
is set toTrue
, expectedfield.formfield()
should berequired=False
however that is not honored.To Reproduce
Steps to reproduce the behavior:
blank=True
Expected behavior
It should appear as not required but it appears as required
Context
Looks like its related to https://github.com/marksweb/django-bleach/blob/0dfcd6de5cbd3719e461f840fcf3b54c5a7fd8b8/django_bleach/models.py#L37-L47
Recently it was changed to return
BleachField
which inherently does not callsuper()
where baseField
correctly interprets other django model field attributes such asblank
:https://github.com/django/django/blob/56f9579105c324ff15250423bf9f8bdf1634cfb4/django/db/models/fields/__init__.py#L908-L914
(copy from link since it does not render inline)