Opened 2 months ago
Last modified 12 days ago
#36127 assigned Bug
The link is not displayed when str is blank in admin.
Description ¶
In the admin page, there are parts where the model's __str__
value is used, providing links that allow navigation to the object when the value is clicked.
However, when __str__
is blank, while it’s not an issue for the value to appear as blank, the <a>
tag's innerHTML
being empty prevents the layout from being displayed on the screen, and it also cannot function as a link.
While it’s very rare for a user to assign a blank value to __str__
, I still believe that it should at least function as a link.
Just like with fields, when the value is blank, a default value such as "-" should be used to ensure that it can at least function as a link.
According to the ticket's flags, the next step(s) to move this issue forward are:
- To improve the patch as described in the pull request review comments or on this ticket, then uncheck "Patch needs improvement".
If creating a new pull request, include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Change History (20)
by , 2 months ago
Attachment: | not_link_example.png added |
---|
comment:1 by , 2 months ago
Owner: | set to |
---|---|
Status: | new → assigned |
Type: | Uncategorized → Bug |
comment:2 by , 2 months ago
Triage Stage: | Unreviewed → Accepted |
---|---|
UI/UX: | set |
by , 2 months ago
Attachment: | Screenshot 2025-01-24 at 8.15.43 AM.png added |
---|
by , 2 months ago
Attachment: | Screenshot 2025-01-24 at 8.16.41 AM.png added |
---|
comment:3 by , 2 months ago
comment:5 by , 2 months ago
Needs tests: | set |
---|
comment:6 by , 2 months ago
Needs tests: | unset |
---|
comment:7 by , 2 months ago
Patch needs improvement: | set |
---|
comment:8 by , 7 weeks ago
Patch needs improvement: | unset |
---|
comment:9 by , 7 weeks ago
I do not know how appropriate it would be as a solution, but specifically for layout collapse it is possible with CSS to detect empty anchor tags and then add a *touch* of content:
a:empty::after { /* insert two non-blocking spaces, making the link appear */ content: '\00A0\00A0'; }
The point here being that there could be some fallback in the admin in particular for this issue (that feels pretty easy to accidentally do when not careful with str). Could even put in text like "(blank)". But then we're looking at translation strings in CSS...
comment:10 by , 6 weeks ago
Patch needs improvement: | set |
---|
comment:11 by , 6 weeks ago
Patch needs improvement: | unset |
---|
follow-up: 14 comment:12 by , 4 weeks ago
Owner: | changed from | to
---|
comment:13 by , 4 weeks ago
Owner: | changed from | to
---|
comment:14 by , 4 weeks ago
Replying to Bhupesh panwar:
Thank you for your interest in this ticket! :) I am currently working on this ticket, and it is now awaiting review.
comment:15 by , 2 weeks ago
Needs tests: | set |
---|
comment:16 by , 2 weeks ago
Needs tests: | unset |
---|
comment:17 by , 12 days ago
Patch needs improvement: | set |
---|
Similar nature to #36114
It will be difficult to find all of these but we can try 👍