"Krondaj wrote:
>I'm using python 2.7.2
>for another model i'm forming i have:
>
>def __unicode__(self):
>    return (self.project_and_task, self.project_number,
>             self.date_created, self.requested_by)
>
>to understand (i think the new method makes a little more sense?) the
>format should be:
>
>def __unicode__(self):
>    return u'{}  {}  {}  {}'.format(self.project_and_task,
>           self.project_number, self.date_created, self.requested_by)
>
>is the two spaces between each {} two seperate the individual strings
>with two spaces?

It is up to you. The purpose of the __unicode__() method
is to return nice and human readable Unicode string
that represents the object. It is used for example 
in the admin mode that was designed to be general for
whatever model.  Whenever the admin template needs to display
textual representation of the whole record as a string, it simply
calls the function for getting a string representation of the whole
object.  The function calls the __unicode__() method that
is implemented by you.  Whatever you want to see in the case
should be created by your definition of the method.  Try to 
put there strings that you can be sure they are yours -- just to
see what the method is called for.

Try  

     u'{}#{}***{}_{}'.format(self.project_and_task,
            self.project_number, self.date_created, self.requested_by)

Also, you are not forced to display all the parts of the record.
It is only for the display purpose.  It should be just a string
that represents the record.  You probably want to put something
meaningful there.

Have a look at http://docs.python.org/library/functions.html#unicode
and http://docs.python.org/reference/datamodel.html#object.__unicode__

Petr

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to