Answer the question
In order to leave comments, you need to log in
How to display "song - performers" data from the M2M connection in the admin panel?
how to make the list "artist - song name" displayed in the admin panel in Song? return what?
class Song(models.Model):
name_song = models.CharField(max_length=30)
...
musician = models.ManyToManyField(Musician)
def __str__(self):
return self.name_song
Answer the question
In order to leave comments, you need to log in
Roman Kitaev помог решить проблему:
def __str__(self):
return '%s - %s' % (', '.join(map(str, self.musician.all())), self.name_song)
def __str__(self):
return '{} - {}'.format(self.name_song, self.musician)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question