Re: Format fields in list, but keep sortable?

2009-12-10 Thread philomat
Chris: Sure, there's that possibility – however, I think it would be very bad practise to insert a redundant field like this, just for formatting matters. Also, one might want the option of using localised units, etc. Shawn: Of course you are generally correct and I know that the core developers

Re: Format fields in list, but keep sortable?

2009-12-08 Thread Shawn Milochik
Bear in mind that the admin has a limited scope. This is intentional. It was meant to be a friendly replacement for having to hit the Postgres/mySQL command line interface, and that's about it. It's trivial to create your own form for dealing with your model which can be customized in any way

Re: Format fields in list, but keep sortable?

2009-12-08 Thread Chris Lawlor
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

Format fields in list, but keep sortable?

2009-12-08 Thread philomat
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"