当前位置: 首页>>代码示例>>Python>>正文


Python query.ModelIterable方法代码示例

本文整理汇总了Python中django.db.models.query.ModelIterable方法的典型用法代码示例。如果您正苦于以下问题:Python query.ModelIterable方法的具体用法?Python query.ModelIterable怎么用?Python query.ModelIterable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.db.models.query的用法示例。


在下文中一共展示了query.ModelIterable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _fetch_all

# 需要导入模块: from django.db.models import query [as 别名]
# 或者: from django.db.models.query import ModelIterable [as 别名]
def _fetch_all(self):
        """
        Completely overrides the QuerySet._fetch_all method by adding the
        timestamp to all objects

        :return: See django.db.models.query.QuerySet._fetch_all for return
            values
        """
        if self._result_cache is None:
            self._result_cache = list(self.iterator())
            # TODO: Do we have to test for ValuesListIterable, ValuesIterable,
            # and FlatValuesListIterable here?
            if self._iterable_class == ModelIterable:
                for x in self._result_cache:
                    self._set_item_querytime(x)
        if self._prefetch_related_lookups and not self._prefetch_done:
            self._prefetch_related_objects() 
开发者ID:swisscom,项目名称:cleanerversion,代码行数:19,代码来源:models.py

示例2: byDay

# 需要导入模块: from django.db.models import query [as 别名]
# 或者: from django.db.models.query import ModelIterable [as 别名]
def byDay(self, fromDate, toDate):
        request = self.request
        class ByDayIterable(ModelIterable):
            def __iter__(self):
                evods = EventsByDayList(fromDate, toDate)
                for page in super().__iter__():
                    pageFromDate = getLocalDate(page.date,
                                                page.time_from, page.tz)
                    pageToDate   = getLocalDate(page.date,
                                                page.time_to, page.tz)
                    thisEvent = ThisEvent(page.title, page,
                                          page.get_url(request))
                    evods.add(thisEvent, pageFromDate, pageToDate)
                yield from evods

        qs = self._clone()
        qs._iterable_class = ByDayIterable
        return qs.filter(date__range=(fromDate - _2days, toDate + _2days)) 
开发者ID:linuxsoftware,项目名称:ls.joyous,代码行数:20,代码来源:events.py

示例3: test_seal_non_sealable_model_iterable_subclass

# 需要导入模块: from django.db.models import query [as 别名]
# 或者: from django.db.models.query import ModelIterable [as 别名]
def test_seal_non_sealable_model_iterable_subclass(self):
        message = (
            "iterable_class <class 'django.db.models.query.ModelIterable'> is not a subclass of SealedModelIterable"
        )
        with self.assertRaisesMessage(TypeError, message):
            SeaGull.objects.seal(iterable_class=ModelIterable) 
开发者ID:charettes,项目名称:django-seal,代码行数:8,代码来源:test_query.py

示例4: this

# 需要导入模块: from django.db.models import query [as 别名]
# 或者: from django.db.models.query import ModelIterable [as 别名]
def this(self):
        request = self.request
        class ThisEventIterable(ModelIterable):
            def __iter__(self):
                for page in super().__iter__():
                    yield ThisEvent(page.title, page, page.get_url(request))
        qs = self._clone()
        qs._iterable_class = ThisEventIterable
        return qs 
开发者ID:linuxsoftware,项目名称:ls.joyous,代码行数:11,代码来源:events.py


注:本文中的django.db.models.query.ModelIterable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。