Don't do that, django recomends to use "python_2_unicode_compatible"
decorator.

https://docs.djangoproject.com/en/dev/topics/python3/#str-and-unicode-methods

2014-11-11 21:08 GMT-02:00 Mike Dewhirst <mi...@dewhirst.com.au>:

> On 12/11/2014 7:26 AM, Jorge Andrés Vergara Ebratt wrote:
>
>> When you are in Python3 you don't use __unicode__ you use __str__
>>
>
> You can leave __unicode__ in place for Python 2.x and add ...
>
> def __str__(self):
>     return self.__unicode__()
>
> ... to satisfy Python 3.x at the same time
>
>
>> On Tue, Nov 11, 2014, 3:14 PMÂ Arjan de Knegt <arjan.de.kn...@gmail.com
>> <mailto:arjan.de.kn...@gmail.com>> wrote:
>>
>>     I am using Django 1.7.1 with python 3.4.0 for my latest project.
>>     I am working on a model called Song. In the admin site all object
>>     that I add show as "Song object" where I would expect the title of
>>     the Song. I have added __unicode__ to the model. is there something
>>     I miss or are things changed in Django 1.7? Below the model and what
>>     is shown in the admin site
>>
>>     _Model:_
>>     class Song(models.Model):
>>     Â Â Â  title = models.CharField(max_length=100, verbose_name =
>> 'Titel')
>>     Â Â Â  author = models.CharField(max_length=100, verbose_name =
>>     'Auteur')
>>     Â Â Â  genre = models.ForeignKey('Genre', to_field='genre')
>>     Â Â Â  featured = models.BooleanField(default = False, verbose_name
>>     = 'featured')
>>     Â Â Â  song_order = models.IntegerField()
>>     Â
>>     Â Â Â  class Meta:
>>     Â Â Â Â Â Â Â  verbose_name = _('Song')
>>     Â Â Â Â Â Â Â  verbose_name_plural = _('Songs')
>>     Â Â Â Â Â Â Â  ordering = ['song_order']
>>
>>     Â Â Â  def __unicode__(self):
>>     Â Â Â Â Â Â Â  return self.title
>>
>>     _Shown in Admin site:_
>>
>>     Song
>>         Song object <http://localhost:8000/admin/playlist/song/1/>
>>         Song object <http://localhost:8000/admin/playlist/song/2/>
>>         Song object <http://localhost:8000/admin/playlist/song/3/>
>>         Song object <http://localhost:8000/admin/playlist/song/4/>
>>
>>
>>     --
>>     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
>>     <mailto:django-users+unsubscr...@googlegroups.com>.
>>     To post to this group, send email to django-users@googlegroups.com
>>     <mailto: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/01cc75ba-
>> 302c-4066-9e4a-fbdc4f3504ea%40googlegroups.com
>>     <https://groups.google.com/d/msgid/django-users/01cc75ba-
>> 302c-4066-9e4a-fbdc4f3504ea%40googlegroups.com?utm_medium=
>> email&utm_source=footer>.
>>     For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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
>> <mailto:django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto: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/CAAeX05F%
>> 3DOUMswk2KQfdLvkrEGkQ9PbztLYBbC44T66WU%2BAYMYw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAAeX05F%
>> 3DOUMswk2KQfdLvkrEGkQ9PbztLYBbC44T66WU%2BAYMYw%40mail.gmail.
>> com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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/546296F2.5060201%40dewhirst.com.au.
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Enviado via UCSMail.

-- 
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/CACctwSgtbozLQiC_Vbn%2B4_%3DkSyOS5_ue1eTLZtBb5OCCWbZzvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to