There is something wrong the way with I treat unicode in python. In Django, part of my model and code is shown below.
class MyTest(models.Model):
address = models.CharField(max_length=100)
def __unicode__(self):
return u'%s,%s' % (self.address, self.city)
I load these values through csv.
records = csv.DictReader(self.cleaned_data["file"])
for line in records:
mt = MyTest()
mt.address=line['ADDRESS'],
mt.city=line['CITY'],
....
mt.save()
print line['ADDRESS']
print mt.address
70 Mall Rd
('70 Mall Rd',)
The problem, in admin template all my values has the brackets around it. Like
('LARGO',), ('FL',),
what could be wrong.
thanks.
It’s tuples with one element, because you add comma in line
mt.address=line['ADDRESS'],andmt.city=line['CITY'],For example: