Я получаю сообщение об ошибке в Django, говорящее Caught TypeError while rendering: sequence item 1: expected string or Unicode, Property found
.Вот мой код:
def __unicode__( self ) :
return "{} : {}".format( self.name, self.location )
Я даже пытался
def __unicode__( self ) :
return unicode( "{} : {}".format( self.name, self.location ) )
, но та же ошибка.
Из того, что я знаю "this is x = {}".format( x )
возвращает строку правильно?Почему Python говорит, что это свойство?
Полный код:
class Item( models.Model ) :
def __unicode__( self ) :
return "{} : {}".format( self.name, self.location )
name = models.CharField( max_length = 135 )
comment = models.TextField( blank = True )
item_type = models.ForeignKey( ItemType )
location = models.ForeignKey( Location )
t_created = models.DateTimeField( auto_now_add = True, verbose_name = 'created' )
t_modified = models.DateTimeField( auto_now = True, verbose_name = 'modified' )
class Location( models.Model ) :
def __unicode__( self ) :
locations = filter( None, [ self.room, self.floor, self.building ] )
locations.append( self.prop )
return ", ".join( locations ) # This will look in the form of like "room, floor, building, property"
comment = models.TextField( blank = True )
room = models.CharField( max_length = 135, blank = True )
floor = models.CharField( max_length = 135, blank = True )
building = models.CharField( max_length = 135, blank = True )
prop = models.ForeignKey( Property )
t_created = models.DateTimeField( auto_now_add = True, verbose_name = 'created' )
t_modified = models.DateTimeField( auto_now = True, verbose_name = 'modified' )
class Property( models.Model ) :
def __unicode__( self ) :
return self.name
name = models.CharField( max_length = 135 )