[Django] #28404: Django admin empty_value/empty_value_display doesn't check for empty strings

183 views
Skip to first unread message

Django

unread,
Jul 17, 2017, 3:53:32 PM7/17/17
to django-...@googlegroups.com
#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.

Django

unread,
Jul 17, 2017, 3:54:03 PM7/17/17
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.11
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage:
admin charfield | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mark Koh):

* Attachment "empty_string bug.png" added.

Empty strings with no empty_value

Django

unread,
Jul 17, 2017, 10:01:46 PM7/17/17
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.11
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage:
admin charfield | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* easy: 1 => 0


Comment:

I'm not immediately convinced that the behavior should be changed instead
of correcting the documentation to reflect the current behavior. Has the
behavior changed since the documentation was introduced in
0207bdd2d4157c542c981264c86706b78ca246e9 or was the original documentation
inaccurate?

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:1>

Django

unread,
Jul 18, 2017, 10:49:44 AM7/18/17
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.11
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage:
admin charfield | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Mark Koh):

The functionality hasn't changed since the documentation was updated, so
it seems as though the original documentation was inaccurate. While I do
have a [https://github.com/django/django/pull/8776 PR in for the fix
(WIP)], I agree that it may make more sense to simply correct the
documentation.
On the other hand, I do feel that this functionality would be useful as an
additional overridable property for the ModelAdmin. Perhaps as an
optional `empty_string_display` property?

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:2>

Django

unread,
Jul 18, 2017, 3:20:45 PM7/18/17
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.11
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage:
admin charfield | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

I've grown wearisome of all the `ModelAdmin` hooks and complexity that
they add. That's the only grounds on which I'd object to an additional
property. If you have a compelling use case, I guess it's okay. I guess
you're finding `empty_value_display` useful?

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:3>

Django

unread,
Jul 19, 2017, 5:01:10 PM7/19/17
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.11
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage:
admin charfield | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Mark Koh):

I would definitely find it useful if it worked with empty strings as well
as `None`. Currently we have a field in our ModelAdmin that is a
`CharField` with `blank=True` and `null=False` and that field is also
specified in the `list_display_links`. Thus, when that field value is an
empty string we are unable to click it (you can see this in the image
attached to this ticket).

Seeing as the `blank=True, null=False` method is the recommended method
for supporting nullable CharFields I imagine that I'm not the only person
whose seen this problem. I am open to either allowing
`empty_value_display` to acknowledge empty strings or to creating a new
optional attribute for empty strings.

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:4>

Django

unread,
Jul 20, 2017, 2:28:34 PM7/20/17
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.11
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


Comment:

I don't know if adding a separate property will be simpler than modifying
the existing `empty_value_display`. I guess there could be use cases for a
separate value for each case. You could write to the DevelopersMailingList
for further feedback.

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:5>

Django

unread,
Jul 24, 2017, 8:19:13 PM7/24/17
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.11
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:6>

Django

unread,
Nov 4, 2017, 7:27:02 AM11/4/17
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Nazarov
| Georgiy
Type: Bug | Status: assigned

Component: contrib.admin | Version: 1.11
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Nazarov Georgiy):

* owner: nobody => Nazarov Georgiy
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:7>

Django

unread,
Nov 27, 2017, 5:38:04 AM11/27/17
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Nazarov
| Georgiy
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
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
-------------------------------------+-------------------------------------
Changes (by Nazarov Georgiy):

* needs_better_patch: 1 => 0
* version: 1.11 => master
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:8>

Django

unread,
Nov 27, 2017, 7:11:20 AM11/27/17
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Nazarov
| Georgiy
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by hui shang):

* stage: Ready for checkin => Accepted


Comment:

Hi, Nazarov Georgiy, you can't check "Ready for checkin" yourself, please
see [https://docs.djangoproject.com/en/1.11/internals/contributing
/triaging-tickets/ triaging-tickets]

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:9>

Django

unread,
Feb 7, 2018, 5:14:10 AM2/7/18
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Nazarov
| Georgiy
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:10>

Django

unread,
Feb 8, 2018, 3:19:26 AM2/8/18
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Nazarov
| Georgiy
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

I haven't yet seen a reason not to re-use `empty_value_display` here
(rather than add a new admin option) but we need to consider when that is
applied:

> There are some cases where I really do want an empty string displayed
(though not in a linked column). Maybe only use it only when it's an auto-
linked field/column? Or maybe only use this behavior in
display_for_field()? (So if you use a custom function/method, you can
still have full control.) — [https://groups.google.com/d/topic/django-
developers/6HbmI3rHdPc/discussion Collin Anderson on Django Dev]

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:11>

Django

unread,
Nov 28, 2019, 10:07:09 AM11/28/19
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Nazarov
| Georgiy
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Sardorbek Imomaliev):

* cc: Sardorbek Imomaliev (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:12>

Django

unread,
Jun 29, 2021, 3:44:47 PM6/29/21
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Nazarov
| Georgiy
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev

Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by fgebala):

Confirming that this is definitely an issue with Django 1.11, and the docs
for 1.11 still say this works for empty strings, which it does not:
https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.empty_value_display.
These docs should be updated to avoid confusion in the future.

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:13>

Django

unread,
Apr 13, 2022, 1:20:44 PM4/13/22
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Nazarov
| Georgiy
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Dominik):

Are there any updates on this?

I just stumbled on this issue when trying to use a "nullable" char field
(blank=True, null=False as the docs suggest) in a changelist filter. The
filter option for the empty string is displayed as a literal empty string,
which results in the surrounding link element collapsing to height 0 and
being virtually unusable since you can't click it. The link itself, once
accessed via inspector works fine.

Docs are also unchanged, so what is the verdict on this issue?

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:14>

Django

unread,
Apr 13, 2022, 2:50:43 PM4/13/22
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Nazarov
| Georgiy
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

Given the `db.models.Field` has
[https://github.com/django/django/blob/62ffc9883afdc0a9f9674702661062508230d7bf/django/db/models/fields/__init__.py#L120
an API that defines what empty values should be] I think that admin logic
should be changed to rely on it?

{{{#!python
diff --git a/django/contrib/admin/templatetags/admin_list.py
b/django/contrib/admin/templatetags/admin_list.py
index 5865843dce..a570026b1e 100644
--- a/django/contrib/admin/templatetags/admin_list.py
+++ b/django/contrib/admin/templatetags/admin_list.py
@@ -227,7 +227,7 @@ def link_in_col(is_first, field_name, cl):
else:
if isinstance(f.remote_field, models.ManyToOneRel):
field_val = getattr(result, f.name)
- if field_val is None:
+ if field_val in f.empty_values:
result_repr = empty_value_display
else:
result_repr = field_va
}}}

That would at least make the notion of ''empty'' coherent between models
and the admin. It kind of blurs the line it terms of what change list
filtering by empty value mean when there's multiple candidates though
(e.g. `CharField(blank=True, null=True)`). Kind of wish we had an
`__empty` lookup for this purpose that would be an alias for all allowed
empty values by the field definition:

{{{#!python
class EmptyModel(models.Model):
text = TextField(blank=True, null=False)
nullable_text = TextField(blank=True, null=True)
integer = IntegerField(blank=True, null=True)
array = ArrayField(TextField(), null=True)
json = JSONField()

EmptyModel.objects.filter(
text__empty=True, # Q(text="")
nullable_text__empty=True, # Q(nullable_text="") |
Q(nullable_text=None)
integer__empty=True, # Q(integer=None)
array__empty=True, # Q(array=[]) | Q(array=None)
json__empty=True, # Q(json=[]) | Q(json={}) | Q(json=None)
)
}}}

If this existed the admin filter could for empty value could basically be
`__empty=True`
[https://github.com/django/django/blob/7119f40c9881666b6f9b5cf7df09ee1d21cc8344/django/contrib/admin/filters.py#L247
instead of] `__isnull=True`.

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:15>

Django

unread,
Apr 19, 2023, 2:25:33 PM4/19/23
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Nazarov
| Georgiy
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* cc: Sarah Boyce (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:16>

Django

unread,
Jan 4, 2024, 5:18:34 PMJan 4
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Alexander
| Lazarević

Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Alexander Lazarević):

* owner: Nazarov Georgiy => Alexander Lazarević


Comment:

After watching how to perform the "vulture method" in (1) I found this
ticket.

According to “Claiming” tickets' I reassign this ticket to myself,
because "... If a ticket has been assigned for weeks or months without any
activity, it’s probably safe to reassign it to yourself." I hope that's
ok.

(1) https://fosstodon.org/@djang...@indieweb.social/111697455678403023

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:17>

Django

unread,
Jan 5, 2024, 2:21:40 AMJan 5
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Alexander
| Lazarević
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Sarah Boyce):

Yes that's completely fine - enjoy!

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:18>

Django

unread,
Jan 5, 2024, 5:58:45 AMJan 5
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Alexander
| Lazarević
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Alexander Lazarević):

New PR https://github.com/django/django/pull/17699

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:19>

Django

unread,
Jan 9, 2024, 5:44:53 AMJan 9
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Alexander
| Lazarević
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"1b0a8991aec7079405be6b4be5fb17d69e1f4ab9" 1b0a899]:
{{{
#!CommitTicketReference repository=""
revision="1b0a8991aec7079405be6b4be5fb17d69e1f4ab9"
Refs #28404 -- Split test_null_display_for_field() test.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:20>

Django

unread,
Jan 10, 2024, 2:44:23 AMJan 10
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Alexander
| Lazarević
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
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
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:21>

Django

unread,
Jan 10, 2024, 3:23:17 AMJan 10
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"9b02ad91ead3db75036be981bab2083aebc993a6" 9b02ad9]:
{{{
#!CommitTicketReference repository=""
revision="9b02ad91ead3db75036be981bab2083aebc993a6"
Fixed #28404 -- Made displaying values in admin respect Field's
empty_values.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:22>

Django

unread,
Jan 10, 2024, 4:13:54 AMJan 10
to django-...@googlegroups.com
#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ć):

Yeah! Thanks for your support, Mariusz!

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:23>

Django

unread,
Jan 10, 2024, 6:56:14 AMJan 10
to django-...@googlegroups.com
#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

unread,
Jan 10, 2024, 3:35:39 PMJan 10
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Alexander
| Lazarević
Type: Bug | Status: new

Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: closed => new
* has_patch: 1 => 0
* resolution: fixed =>


* stage: Ready for checkin => Accepted


Comment:

Agreed, let's reopen.

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:25>

Django

unread,
Jan 10, 2024, 11:58:26 PMJan 10
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Alexander
| Lazarević
Type: Bug | Status: new
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: empty value display | Triage Stage: Accepted
admin charfield |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Alexander Lazarević):

* has_patch: 0 => 1


Comment:

Additional PR https://github.com/django/django/pull/17720

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:26>

Django

unread,
Jan 11, 2024, 6:48:34 AMJan 11
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Alexander
| Lazarević
Type: Bug | Status: assigned

Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
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
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => assigned

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:27>

Django

unread,
Jan 11, 2024, 10:14:20 AMJan 11
to django-...@googlegroups.com
#28404: Django admin empty_value/empty_value_display doesn't check for empty
strings
-------------------------------------+-------------------------------------
Reporter: Mark Koh | Owner: Alexander
| Lazarević
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
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 Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"4787972c941b0d090cf083e84a98c1791bb2ae4b" 4787972]:
{{{
#!CommitTicketReference repository=""
revision="4787972c941b0d090cf083e84a98c1791bb2ae4b"
Refs #28404 -- Made displaying property values in admin respect non-None
empty values.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:28>

Django

unread,
Jan 11, 2024, 1:05:53 PMJan 11
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: assigned => closed
* resolution: => fixed


--
Ticket URL: <https://code.djangoproject.com/ticket/28404#comment:29>

Reply all
Reply to author
Forward
0 new messages