You could add a field to store the calculated size, and override the model's save method to perform the necessary calculation. Something like:
def save(self, force_insert=False, force_update=False): self.size_formatted = self.width * self.height // or whatever your calculation actually is super(ModelName, self).save(force_insert, force_update) Be sure to replace 'ModelName' with the name of your model. On Dec 8, 7:18 am, philomat <samuel.luesc...@gmail.com> wrote: > Hi, > > I keep numeric fields like "size", "width", "height" in my database. > In the admin, I want to render them in a friendly format and attach > units like "KiB" or "pixels" to them when showing them in the change > list. I know this could easily be achieved by adding callables such as > "size_formatted" etc to list_display. However, these are no longer > sortable. > > Is there a way around this limitation? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.