Hi!
We've recently hit upon a problem where we need empty strings in a CharField to be coerced to NULL. Obviously nullable CharField's are frowned upon but we have the requirement that non-empty values must be unique, so the empty state must be NULL.
We've written a custom subclass of CharField to deal with this, but when I found the bug report[1] for this issue, the wontfix justification was that it would make things backwards incompatible. What I'm proposing instead is we add another option to CharField's __init__ which defaults to true called "allow_empty_strings". If set to False, and the field is nullable, this would coerce empty values to None. If the field was not nullable, this would raise an exception (ValueError?, IntegrityError?).
Is this an acceptable solution to support this use-case?
Thanks,
Luke.
[1]
https://code.djangoproject.com/ticket/9590