如何仅从管理面板中创建的组中的用户中进行选择?在外键中,这可以通过limit\u choices\u to完成,而在MtM中则不知道。谷歌没有帮助。
class Application(models.Model):
STATUS_CHOICES = (
('In the work', 'Ð ÑабоÑе'),
('New', 'ÐоваÑ'),
('Complited', 'ÐавеÑÑена')
)
author = models.ForeignKey(User, related_name = 'author', null = True)
title = models.CharField(max_length=50)
text = models.TextField()
room = models.CharField(max_length = 5)
published_date = models.DateField(blank=True, null=True, default = datetime.datetime.now)
status = models.CharField(max_length=15, choices=STATUS_CHOICES, default='New')
owner = models.ManyToManyField(User)
def __str__(self):
return self.title