python - django __unicode__: \n and manytomany? -


class nickname(models.model):     name = models.charfield()      def __unicode__(self):         return unicode(self.name)  class bob(models.model):      bob_nickname = models.manytomanyfield(nickname)      def __unicode__(self):         return unicode(self.bob_nickname) 

number1. how __unicode__ class bob display actual fk name, rather <django.db.models.fields.related.manyrelatedfieldsmanager object @ 0xdsfjk>?

edit: doing self.bob_nickname.all() seems work fine. aint pretty, displays info: [<nickname: ron>,<nickname: randy>]

number2. also, how can def __unicode__ not escape \n? i'd create multiline unicode string

thank you!

why don't use values_list related nick_names list?

class bob(models.model):     bob_nickname = models.manytomanyfield(nickname)      def __unicode__(self):         return u'\n'.join(self.bob_nickname.values_list('name', flat=true)) 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -