當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。