hmarr/mongoengine — Issue #398: problem with limiting queryset in DTL
Author: tkloc
Created: 2011-12-26 17:52:49+00:00
State: open

Hello,

Sorry for lack of testcase, but i really don't know how to write test for this case.

I have a simple model

```python
class MTest(Document):
name = StringField()
meta = {'collection': 'mtest'}
```

with some data:

```python
In [2]: for i in range(20):
...: m = MTest(name=str(i))
...: m.save()
```

and next do some pagination:

```python
In [4]: from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
In [5]: paginator = Paginator(MTest.objects.all(), 2)
```

when I get page and print number of objects (page.objects_list.count()) in django view - values are correct (2), but in template i see very strange behaviour:
page number | number of results
1 | 2
2 | 4
3 | 6
4 | 8
5 | 10
6 | 10
7 | 8
8 | 6
9 | 4
10 | 2

I've described some details in mailing list, but my hack (print self / self.__repr__() ) doesn't work as i expected, because it mess up some other things.