Hi Jean Baptiste. Did you find a solution to your issue? I am in the same situation and your explanation is the closest that I have found.
Thanks... El viernes, 2 de diciembre de 2016, 15:33:22 (UTC+1), Jean-Baptiste Pressac escribió: > > Hello, > Thanks Carlos but modifying TypeOeuvre as suggested > > def __unicode__(self): > return self.intitule.__str__ > > > generates the following error : > > Exception Type: TypeError at /admin/prelib/typeoeuvre/11/delete/Exception > Value: __str__ returned non-string (type method-wrapper) > > > 2016-12-02 15:06 GMT+01:00 Carlos Andre <[email protected] <javascript:>>: > >> def __unicode__(self): >> return "{0} [{1}]".format(self.titre[:200], self.id).__str__ >> >> def __unicode__(self): >> return self.intitule.__str__ >> >> >> 2016-12-02 10:03 GMT-03:00 Jean-Baptiste Pressac <[email protected] >> <javascript:>>: >> >>> Hello, >>> On Django 1.8 + Python 2.7.11, I have declared in Django admin.py an >>> oeuvre class with a ManyToManyField (types) to an TypeOeuvre class. >>> >>> >>> class Oeuvre(models.Model): >>> titre = models.CharField(max_length=510) >>> types = models.ManyToManyField('TypeOeuvre', >>> blank=True, >>> verbose_name="Type(s) de l'œuvre") >>> class Meta: >>> ordering = ['titre'] >>> >>> def __unicode__(self): >>> return "{0} [{1}]".format(self.titre[:200], self.id) >>> >>> class TypeOeuvre(models.Model): >>> intitule = models.CharField(max_length=100, verbose_name='Intitulé') >>> commentaire = models.CharField(max_length=255, >>> verbose_name='Commentaire', >>> blank=True) >>> >>> class Meta: >>> ordering = ['intitule'] >>> verbose_name = "Type d'œuvre" >>> verbose_name_plural = "Types d'œuvres" >>> >>> def __unicode__(self): >>> return self.intitule >>> >>> >>> >>> When I try to delete a TypeOeuvre object in Django Admin for which >>> relations to one oeuvre exists, the "Are you sure?" warning do not >>> explicitly mention the name of the oeuvre but displays a list of: >>> >>> Oeuvre-typeoeuvre relationship: Oeuvre_types object >>> >>> I also reproduced the problem on Django 1.10 + Python 3.4.5 and using >>> __str__ instead of __unicode__. >>> >>> >>> Is there a way to display the name of the oeuvres linked to the type ? >>> >>> >>> Thanks, >>> >>> >>> <https://lh3.googleusercontent.com/-NLq1ATA5oP0/WEFvnIVgHOI/AAAAAAAADrY/quRoC9RxDVcwFhD8iEnkHfnhjammcsIUACLcB/s1600/3gT0J.png> >>> >>> >>> >>> >>> -- >>> 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 [email protected] <javascript:>. >>> To post to this group, send email to [email protected] >>> <javascript:>. >>> Visit this group at https://groups.google.com/group/django-users. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/f62bac64-d292-46ee-b23a-e0fc7a630706%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/django-users/f62bac64-d292-46ee-b23a-e0fc7a630706%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 a topic in the >> Google Groups "Django users" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/django-users/MjQ-Dh2p4eQ/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CAA8yBMyvpT-ZfsoA48utAAy_-ghduitc_FHSXM2K5zBxvyqXQA%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/django-users/CAA8yBMyvpT-ZfsoA48utAAy_-ghduitc_FHSXM2K5zBxvyqXQA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Jean Baptiste Pressac > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/72a32244-a6cf-49cf-9630-6708654fbafc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

