On Wednesday, March 16, 2011 5:37:23 PM UTC, Vinicius Massuchetto wrote: > > I want to customize the DateTimeField returned in an admin list > column. I know there's the DATETIME_FORMAT setting, but I only want to > change in one model. I'lm also using L10N, and couldn't figure out if > there's a way to override what's in the default po file for my > language. > > What's the right way of doing that? Please note that I want to > preserve the sorting feature of this column. > > Many thanks. > -- > Vinicius Massuchetto >
Create a custom admin method that returns the formatted value, and specify that in the `list_display` method. Make sure you set the `admin_order_field` property on the method to preserve the ordering functionality. class MyAdmin(admin.ModelAdmin): list_display = ('name', 'my_date_display') def my_date_display(self, obj): return obj.my_date_field.strftime('your-display-format') my_date_display.admin_order_field = 'my_date_field' -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.