jazzband / jazzband/django-floppyforms

Why is the value of a Checkbox forced to None?

Open
#182 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
836
Forks
150
PR merge metrics
No merged PRs in 30d

Description

The `_format_value` of a `CheckBoxInput` returns `None` if value is valid (`True` or `False`) .

See [Line 446](https://github.com/gregmuellegger/django-floppyforms/blob/master/floppyforms/widgets.py#L446)
```
def _format_value(self, value):
if value in ('', True, False, None):
value = None
else:
value = force_text(value)
return value
```

Why don't keep the value as it is rather than returning `None`? I think this cause a different behavior from other field types.

In my case, it caused a bug when upgrading an application and it was very difficult to find.

Thanks for explaining the reason.

Best
luc

Contributor guide

Open the contributing guide

Research direction

Read floppyforms/widgets.py at line 446 and trace how CheckBoxInput._format_value handles True, False, empty strings, and None. Compare this behavior with other field types and determine the expected checkbox value handling; the issue is complete when the behavior or its rationale is clarified and the reported upgrade difference is addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.