Попытка вернуть на странице администратора имя таблицы manytomanyfield в функции списка с разделением запятыми.
class Machine(models.Model):
class Meta:
verbose_name = 'Machine'
verbose_name_plural = '02 Machines'
machine_type_choices = (...)
valuestream = models.ForeignKey(Valuestream, on_delete=models.CASCADE)
machine_number = models.CharField(
max_length=6,
help_text="Please exclude the 'm' in the machine number",
unique=True,
validators=[
MinLengthValidator(4, message="Machine numbers have to be greater than 3 digits long"),
]
)
machine_type = models.CharField(max_length=50, choices=machine_type_choices)
machine_brand = models.CharField(max_length=30, blank=True)
pub_date = models.DateTimeField(auto_now=True)
pass
def __str__(self):
return str(self.machine_number)
class SWS_Document(models.Model):
class Meta:
verbose_name = 'SWS Document'
verbose_name_plural = '03 SWS Documents'
machines = models.ManyToManyField(Machine, related_name='SWS_documents')
document_description = models.CharField(max_length=150, default="")
pub_date = models.DateTimeField(auto_now=True)
def __str__(self):
return str(self.machines.machine)
Последний бит кода - это то, что я не могу понять.Я пытаюсь вернуть все связанные машины в списке, связанном с SWS_Document.