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
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,
def __unicode__(self): return "{0} [{1}]".format(self.titre[:200], self.id).__str__def __unicode__(self): return self.intitule.__str__
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
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.
For more options, visit https://groups.google.com/d/optout.
def __unicode__(self):
return self.intitule.__str__--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
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.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
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.
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 django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
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.
--Jean Baptiste Pressac