Igor,

Are you looking for a more meaningful label, say using string interpolation:

def __unicode__(self):
     return "Manufacturer: %s, Serial no: %s" % (manufacturer, 
serial_number)



On Thursday, 9 January 2014 12:10:07 UTC+5:30, Igor Korot wrote:
>
> Tundebabzy,
> I understand that.
> But at the same time it should make some sense, otherwise what is the 
> point of having this label (__unicode__() function), right?
>
> 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/74513893-d836-40f4-ae93-2b8f3db6798b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to