Answer the question
In order to leave comments, you need to log in
How to shorten text in Django admin?
Maybe a stupid question, but is it possible to somehow limit the text of a row in a table (in the django admin) so that all rows are the same size?
Answer the question
In order to leave comments, you need to log in
In the model, you add a string truncation function, for example:
def trim50(self):
return u"%s..." % (self.szYouFileldNeedTrim[:50],)
szYouFileldNeedTrim
that you want to shorten when outputting, you specify this function trim50
. When editing a record, real fields will be loaded (i.e. in our case, szYouFileldNeedTrim ), and in the record label, a synonym for trim50
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question