#34635: ModelChoiceField with a to_attr that can have an EMPTY_VALUE
----------------------------------+--------------------------------------
Reporter: Willem Van Onsem | Owner: nobody
Type: Uncategorized | Status: closed
Component: Forms | Version: 4.2
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Comment (by David Sanders):
imho this is exactly what blank is for :P
https://docs.djangoproject.com/en/4.2/ref/models/fields/#blank
> If True, the field is allowed to be blank … Note that this is different
than null. null is purely database-related, whereas blank is validation-
related. If a field has blank=True, form validation will allow entry of an
empty value.
The key here is that `""` is an empty value. `blank=True` is declaring
that empty values are permissible.
> since it seems to suggest that you leave the *reference* blank
Are you referring to `null/None` ? 🤔
> So it seems counterintuitive, and misleading.
And so the `NULL` debate rages on 😅
--
Ticket URL: <https://code.djangoproject.com/ticket/34635#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701888fef9f18-66d4d189-fd7e-4807-a34a-b13c97c544b2-000000%40eu-central-1.amazonses.com.