Opened 5 years ago

Last modified 3 months ago

#15188 assigned New feature

ellipsizing fields in list_display in admin

Reported by: bjourne Owned by: giuliettamasina
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 giuliettamasina 3 months ago.
Test project to illustrate long list_filter fields

Download all attachments as: .zip

Change History (10)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by jasonkotenko

  • Owner changed from nobody to jasonkotenko
  • Status changed from new to assigned

comment:3 Changed 5 years ago by jasonkotenko

  • Cc kotenko@… added
  • Owner changed from jasonkotenko to nobody
  • Status changed from assigned to new

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 5 years ago by jasonkotenko (previous) (diff)

comment:4 Changed 5 years ago by lrekucki

  • Severity set to Normal
  • Type set to New feature

comment:5 Changed 5 years ago by julien

  • UI/UX set

comment:6 Changed 4 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:7 Changed 4 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:8 Changed 4 years ago by aaugustin

  • UI/UX set

Revert accidental batch modification.

Changed 3 months ago by giuliettamasina

Test project to illustrate long list_filter fields

comment:9 Changed 3 months ago by giuliettamasina

  • Owner changed from nobody to giuliettamasina
  • Status changed from new to assigned

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

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