Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Django管理器中返回空queryset_Python_Django_Django 1.10 - Fatal编程技术网

Python 在Django管理器中返回空queryset

Python 在Django管理器中返回空queryset,python,django,django-1.10,Python,Django,Django 1.10,如何在Django manager中返回空查询集 class EventDateRangeManager(models.Manager): def occurring_in_day(self, year, month, day): try: picked_date = datetime.date(int(year), int(month), int(day)) except (TypeError, ValueError):

如何在Django manager中返回空查询集

class EventDateRangeManager(models.Manager):

    def occurring_in_day(self, year, month, day):
        try:
            picked_date = datetime.date(int(year), int(month), int(day))
        except (TypeError, ValueError):
            return an empty query set here

        return self.get_queryset().filter(
            start_day__lte=picked_date,
            end_day__gte=picked_date,
        )

找到了答案


返回self.none()

找到了答案

它是
返回self.none()