Friday, September 10, 2010

Color code not working on admin listing table list_display.

Following http://docs.djangoproject.com/en/dev/ref/contrib/admin/

class Person(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
color_code = models.CharField(max_length=6)

def colored_name(self):
return '<span style="color: #%s;">%s %s</span>' %
(self.color_code, self.first_name, self.last_name)
colored_name.allow_tags = True

class PersonAdmin(admin.ModelAdmin):
list_display = ('first_name', 'last_name', 'colored_name')

It's not showing any color. I checked the html source code. It did
have these style codes.
What's the reason. How to fix? thanks.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment