[英]MultiSelectField in Django Models
Suppose, I have a list of professionals. 假设我有一个专业人员列表。 I need to filter them based on their availability(Monday, Tuesday...etc).
我需要根据其可用性(星期一,星期二等)过滤它们。 For example, a professional can select Monday and Tuesday as his available days.
例如,专业人员可以选择星期一和星期二作为他的工作日。 How can I implement this in Django models.
我如何在Django模型中实现这一点。 Is there any way?
有什么办法吗? NB : I'm not refering to Django Forms or MultiChoiceFields or Choice fields.
注意:我指的不是Django Forms或MultiChoiceFields或Choice字段。 Also I'm using Django 1.9, Is there anyway to use the widget django-multiselectfield in here successfully.
另外,我正在使用Django 1.9,是否可以在这里成功使用django-multiselectfield小部件。 Coz I've already tried all possibilities.
因为我已经尝试了所有可能。 Thanks in advance
提前致谢
I would propose something like this: 我会提出这样的建议:
DAY_CHOICES = (
('01', 'Sunday'),
('02', 'Monday'),
# etc
)
class Professional(models.Model):
# add smth here
class Record (models.Model):
professional = models.ForeignKey(Professional, null=True),
availability = models.CharField(
_('available'), max_length=10,
choices=DAY_CHOICES,
blank=True, null=True,
)
class Timetable (models.Model):
record = models.ForeignKey(Record, null=True),
So you will be able to filter either professionals or days or both 因此,您将可以过滤专业人员或天数,或两者都过滤
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.