#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Alexander
| Lazarević
Type: Bug | Status: closed
Component: contrib.admin | Version: dev
Severity: Normal | Resolution: fixed
Keywords: empty value display | Triage Stage: Ready for
admin charfield | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Alexander Lazarević):
I'm afraid my PR might not have been complete. I just tried something like
this:
{{{
@admin.register(SomeModel)
class SomeModelAdmin(admin.ModelAdmin):
list_display = (
"name",
"description",
"my_description",
)
empty_value_display = "-empty-"
@admin.display(empty_value="-very empty-")
def my_description(self, obj):
return "" # obj.description
}}}
and it did not show the "-very empty-" string.
I guess this needs to be changed as well:
{{{
def display_for_value(value, empty_value_display, boolean=False):
from django.contrib.admin.templatetags.admin_list import _boolean_icon
if boolean:
return _boolean_icon(value)
elif value is None: <-------------------------
return empty_value_display
elif isinstance(value, bool):
return str(value)
...
}}}
Can somebody please confirm this? Sorry for not seeing it earlier ...
--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:24>
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/0107018cf33ad719-d8a601f3-e750-46fd-883a-87018fd97e20-000000%40eu-central-1.amazonses.com.