I wanted the date in this format:
%A
%d %B %Y
%H:%M:%S

I found a solution to point #2:

format_data = re.compile(r'(?<=\d)\s(?=[A-Za-z])|(?<=[A-Za-z])\s(?=\d)',
re.LOCALE | re.UNICODE)

list_display = ('x',)

def x(self, row):
....return mark_safe(format_data.sub('&nbsp;',
formats.localize(row.call_start)))
x.allow_tags = True

I still have to find out the solution to #1...


On Wed, May 5, 2010 at 12:48, Massimiliano della Rovere
<massimiliano.dellarov...@gmail.com> wrote:
> 1st question) I am trying to change the way some of DateTimeField are
> displayed in the change_list page of the admin site (django 1.2 svn):
> how to do it?
>
> Not knowing which method to define or override in the ModelAdmin
> class, I opted for a different solution:
> I added a string in the list_display tuple and then I defined a
> homonimous method:
>
> list_display = ('x',)
>
> def x(self, row):
> ....return mark_safe(row.call_start.strftime(u'%Y-%m-%d<br/>%H:%M:%S'))
>
> 2nd question) why the "<>" signs in the strings are escaped in the
> change_list page even though they are marked safe?
>

-- 
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.

Reply via email to