Skip to content

CharField with blank=True should not be considered nullable #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Naddiseo opened this issue Mar 4, 2019 · 1 comment · Fixed by #39
Closed

CharField with blank=True should not be considered nullable #38

Naddiseo opened this issue Mar 4, 2019 · 1 comment · Fixed by #39

Comments

@Naddiseo
Copy link
Contributor

Naddiseo commented Mar 4, 2019

AFAIK, CharField(blank=True,...) just means that the string can be 0-length, and doesn't mean that it's Optional/nullable. The documentation on blank also seems to suggest this, saying that it "will allow the entry of an empty value", which for a string is just a 0-length string.

I think the offending code is fields.py:105

I can make a pull request to remove (or comment out) that block of code if needed

@mkurnikov
Copy link
Member

It's fine to remove it. Thanks!

Naddiseo added a commit to Naddiseo/django-stubs that referenced this issue Mar 4, 2019
The documentation on [blank](https://docs.djangoproject.com/en/2.1/ref/models/fields/#blank) says that it "will allow the entry of an empty value", which for a string is just a 0-length string. This patch allows `CharField(blank=True,...)` to no longer be considered `Optional`.

closes typeddjango#38
mkurnikov pushed a commit that referenced this issue Mar 5, 2019
* Make CharField(blank=True) not be considered nullable

The documentation on [blank](https://docs.djangoproject.com/en/2.1/ref/models/fields/#blank) says that it "will allow the entry of an empty value", which for a string is just a 0-length string. This patch allows `CharField(blank=True,...)` to no longer be considered `Optional`.

closes #38

* fixed tests for `CharField(blank=True)`

* allow blank CharField to be nullable in the constructor, but the underlying type
is str (unless `null=True`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants