Opened 6 years ago

Closed 4 months ago

#15188 closed New feature (duplicate)

ellipsizing fields in list_display in admin

Reported by: bjourne Owned by: Markus Amalthea Magnuson
Component: contrib.admin Version: 1.2
Severity: Normal Keywords:
Cc: kotenko@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

In the list_display for a model I have there are two url fields. When the urls are long, they word wrap which doesn't look good. I would prefer if there was some system in place to ellipsize fields instead of word wrapping.

Attachments (1)

ellipsis_admin.zip (14.7 KB) - added by Markus Amalthea Magnuson 8 months ago.
Test project to illustrate long list_filter fields

Download all attachments as: .zip

Change History (11)

comment:1 Changed 6 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

comment:2 Changed 6 years ago by Jason Kotenko

Owner: changed from nobody to Jason Kotenko
Status: newassigned

comment:3 Changed 6 years ago by Jason Kotenko

Cc: kotenko@… added
Owner: changed from Jason Kotenko to nobody
Status: assignednew

I'm looking through the source on this one, and I'm beginning to wonder what the correct approach is. It appears that the actual code which produces the items in the Change List is the template tag helper function "items_for_result" starting line 128 in django/contrib/admin/templatetags/admin_list.py.

The function handles every type of field the same, just outputting the unicode representation inside a <td> element. It appears to me, that if we place an exception for long URLs, we would have to introduce a "magic number".

Is the right place for this in a javascript file, since the size at which to ellipsize a field depends on the size of the user's browser? I'm going to relinquish control of the bug for now but keep my eye on it. I'm not ready to delve into the django javascript yet.

Last edited 6 years ago by Jason Kotenko (previous) (diff)

comment:4 Changed 6 years ago by Łukasz Rekucki

Severity: Normal
Type: New feature

comment:5 Changed 6 years ago by Julien Phalip

UI/UX: set

comment:6 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:7 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:8 Changed 5 years ago by Aymeric Augustin

UI/UX: set

Revert accidental batch modification.

Changed 8 months ago by Markus Amalthea Magnuson

Attachment: ellipsis_admin.zip added

Test project to illustrate long list_filter fields

comment:9 Changed 8 months ago by Markus Amalthea Magnuson

Owner: changed from nobody to Markus Amalthea Magnuson
Status: newassigned

It seems like long lines in list_filter fields in admin are not wrapped anymore if they are entirely uninterrupted by e.g. hyphens, spaces etc. Instead they overflow with a horizontal scrollbar. Attached is a test project that illustrates this through a very long URL, per the original ticket. (The project has migrations that create the data and an admin user.)

  1. Download and unzip the project
  2. Create a virtual env and pip install django
  3. ./manage.py migrate
  4. ./manage.py runserver
  5. Go to http://localhost:8000/admin/app/mymodel/ and log in with user "test" and password "test"

This ticket might be a wontfix, in favor of https://code.djangoproject.com/ticket/26066

comment:10 Changed 4 months ago by Tim Graham

Resolution: duplicate
Status: assignedclosed

Closing as a duplicate of #26066

Note: See TracTickets for help on using tickets.
Back to Top