Think about it like this. A class is a box with something inside. The
__unicode__ method is putting a label on the box to describe what is inside
the box. The label doesn't have to be there and if its there, it can have
anything written on it (which should make sense to the person writing it).
The purpose of the label is to let anybody know what is inside the box.

Hope that helps
On 9 Jan 2014 01:39, "Igor Korot" <ikoro...@gmail.com> wrote:

> Hi, Avraham,
> So, lets say I write something like this:
>
> [code]
> def __unicode__(self):
>      return (%s %s) manufacturer, serial_number
> [/code]
>
> and in tutorial part 1 I will go to the section "Play with API" I will
> still see 2 different fields when I issue: "Stuff.objects.all()"?
>
> Because as far as I understand those 2 fields will be displayed as one.
>
> Thank you.
>
>
> On Wednesday, January 8, 2014 3:03:58 PM UTC-8, Igor Korot wrote:
>>
>> Hi, ALL,
>> In the tutorial it is said that I need to create __unicode__() function
>> to properly display the results of my model.
>> Unfortunately the tutorial is using only one text field and everywhere I
>> looked people are using something related, i.e. first_name+last_name and so
>> they can create a tuple.
>>
>> What if my strings are not related to each other at all?
>> For example I might have:
>>
>> from django.db import models
>>
>> class Stuff(models.Model):
>>      Manufacturer = models.CharField(max_length=100)
>>      Serial_number = models.CharField(max_length=20)
>>
>> manufacturer and serial_number are not related and I don't want them to
>> be displayed as one field in the output.
>> So what the __unicode__() function will look like in this case?
>>
>> Thank you.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9f1ac883-a573-4f02-b9ef-c6f6e57c6453%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BWjgXPO%3DPEnRZKAkwZwgYE5Fm8wrSTTsTEa35495-jayVioCw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to