#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.11
contrib.admin | Keywords: empty value display
Severity: Normal | admin charfield
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 1 |
-------------------------------------+-------------------------------------
According to the
[https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#django.contrib.admin.ModelAdmin.empty_value_display
Django documentation], `empty_value_display` should "display value for
record’s fields that are empty (None, empty string, etc.)" However,
currently this value is only returned when the field value is '''None'''
and does not check for empty strings. This can be seen here -
https://github.com/django/django/blob/5a52d932ef4da8228d82673314341c2c86602248/django/contrib/admin/utils.py#L420
Thus, if you have a CharField with a value of `''` (empty string), the
`empty_value_display` value will not appear, contrary to the
documentation.
How to reproduce:
- Create a model with a `CharField(blank=True, null=True)`
- Create a model_admin and add that field to the `list_display` list
- Create two instances of the model, one with that field set to None and
another with it set to `''` (empty string)
- Open the admin panel and find those models, you will see that the
instance with None shows `-` but the one with the empty string shows
nothing.
--
Ticket URL: <https://code.djangoproject.com/ticket/28404>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.b849b7db514c6348c62cbb3c4f30a87f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.