i m getting this error:
>>> Child.objects.all()
Traceback (most recent call last):
File "<input>", line 1, in <module>
Child.objects.all()
u = six.text_type(self)
TypeError: coercing to Unicode: need string or buffer, Main found
Whenever i try to pull an object from Child. i tried to use the unicode but it still gives me this error. I also commented the **def str ** thought that was a problem. I don't know what i can do about it? Please help
class Main(models.Model):
website = models.CharField(db_column='Website', unique=True, max_length=250)
main = models.CharField(db_column='Main', unique=True, max_length=100)
tablename = models.CharField(db_column='TableName', unique=True, max_length=100)
created_at = models.DateTimeField(db_column='Created_at')
class Meta:
managed = False
db_table = 'Main'
# def __str__(self):
# return self.main
def __unicode__(self):
return unicode(self.main)
class Child(models.Model):
mainid = models.ForeignKey(Main, models.DO_NOTHING, db_column='MainID')
day = models.IntegerField(db_column='Day')
hour = models.TimeField(db_column='HOUR')
created_at = models.DateTimeField(db_column='Created_at')
class Meta:
managed = False
db_table = 'Child'
# def __str__(self):
# return self.mainid
def __unicode__(self):
return unicode(self.mainid)
Thank you
# -*- coding: utf8 -*-