Tuesday, January 24, 2012

django docs __unicode__ return u'%s %s

Hi,

in the django docs about __unicode__ it says the following:

class Person(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)

def __unicode__(self):
return u'%s %s' % (self.first_name, self.last_name)

what does the u'%s %s' % mean... I cannot find any exaplanation of
this in the docs?

i've seen this in someones code that was kindly lent to me by one of
the RC chat room people:

return u'ID%s: %s - %s - %s - %s' % (self.id, self.user,
self.question, self.answer, self.get_status_display())

but all this u' %s %s' %%%sss or what ever is most confusing....

is there a document or help guide some where that explains this
nomenclature, or method, system???

as I believe if you take the top example you should be able to do:
def __unicode__(self):
return(self.first_name, self.last_name)

If there is no documentation (for dummies) can anyone explain it to
me??

Thanks

Krondaj

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate