Have ascii coding error in django admin?

Март 10, 2010

If you have some unicode data in tables e.g. some Russian names and want them to be displayed  by default you need to do some trick:

class SomeTable(models.Model):
	name = models.CharField(max_length=def_max_length)	

	def __unicode__(self):
		return "%s" % self.name

See that — instead of returning self.name directly I returned «%s» % self.name and admin panel is shining!

tags: ,
posted in Python, Web by dmitko

Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org