Kaynağa Gözat

Document change to Range interface

master
David Winterbottom 11 yıl önce
ebeveyn
işleme
56556db6d2

+ 6
- 1
docs/source/howto/how_to_create_a_custom_range.rst Dosyayı Görüntüle

@@ -27,6 +27,8 @@ A custom range must:
27 27
   boolean
28 28
 * have a ``num_products`` method that returns the number of products in the
29 29
   range or ``None`` if such a query would be too expensive.
30
+* have an ``all_products`` method that returns a queryset of all products in the
31
+  range.
30 32
 
31 33
 Example::
32 34
 
@@ -37,7 +39,10 @@ Example::
37 39
             return "!" in product.title
38 40
 
39 41
         def num_products(self):
40
-            return Product.objects.filter(title__icontains="!").count()
42
+            return self.all_products().count()
43
+
44
+        def all_products(self):
45
+            return Product.objects.filter(title__icontains="!")
41 46
 
42 47
 Create range instance
43 48
 ---------------------

Loading…
İptal
Kaydet