mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #2351 -- Fixed problem with using ".count" attribute of QuerySets in
templates. git-svn-id: http://code.djangoproject.com/svn/django/trunk@4772 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
29aa31d8f5
commit
858ac05802
1 changed files with 2 additions and 0 deletions
|
@ -109,6 +109,8 @@ class QuerySet(object):
|
||||||
|
|
||||||
def __getitem__(self, k):
|
def __getitem__(self, k):
|
||||||
"Retrieve an item or slice from the set of results."
|
"Retrieve an item or slice from the set of results."
|
||||||
|
if not isinstance(k, (slice, int)):
|
||||||
|
raise TypeError
|
||||||
assert (not isinstance(k, slice) and (k >= 0)) \
|
assert (not isinstance(k, slice) and (k >= 0)) \
|
||||||
or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0)), \
|
or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0)), \
|
||||||
"Negative indexing is not supported."
|
"Negative indexing is not supported."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue