class DayOfWeek(models.Model):
name = models.CharField(max_length=45)
class PermanentShiftSchedule(models.Model):
id = models.UUIDField(primary_key=True, editable=False, default=uuid4)
shift = models.ForeignKey(Shift, related_name='shift_permanent_schedule', on_delete=models.CASCADE)
branch_employee = models.ForeignKey(BranchEmployee, related_name='branch_emp_permanent_schedule',
on_delete=models.CASCADE)
days_of_week = models.ManyToManyField(DayOfWeek, related_name='permanent_shift_days')
现在我要过滤PermanentShiftSchedule,其中 days_of_week 字段contanins“星期四”
days_of_week 字段可能包含多天名称
答案 0 :(得分:1)
您可以尝试按相关使用双下划线__
PermanentShiftSchedule.objects.filter(days_of_week__name__icontains="Thursday")