Or you can apply a CSS with overflow: ellipsis; whichever fits you.
On 14 Nov 2015 17:10, "Simon Charette" <charette.s@gmail.com> wrote:
-- Hi Jorgue,--
You can simply define a `list_display` method that truncates your text if required and append an ellipsis.
e.g.
class FooAdmin(admin.ModelAdmin):
list_display = ['text_field_ellipsis']
def text_field_ellipsis(self, obj):
if len(obj.text_field) > max_length:
return "%s..." % obj.text_field[:max_length]
return obj.text_field
Cheers,
Simon
Le samedi 14 novembre 2015 10:49:09 UTC-5, Jorge Fernandez-de-Cossio-Diaz a écrit :A column of my Django admin interface sometimes has too much text. When this happens, I would like to replace the last part of the text with "...", so that the column width doesn't gets past a maximum character count. How can I do this?
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f86671ca-0645-4567-a3b2-1372d55f7308%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACczBU%2BZwzpgbAQGTBXx%2ByFRdi6ri%3DveUy%3DpQrUrOrHXa0%2BZGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment