Opened 13 years ago
Closed 13 years ago
#17523 closed Bug (duplicate)
Slicing: EmptyQuerySet behaves differently from QuerySet
Reported by: | rluedeman | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I noticed a slight (but annoying) difference between slicing an EmptyQuerySet and slicing a standard QuerySet. It seems like slicing an EmptyQuerySet should return an EmptyQuerySet, rather than returning a list.
Example:
>> from django.contrib.auth.models import User >> >> type(User.objects.all()) <class 'django.db.models.query.QuerySet'> >> type(User.objects.all()[:0]) <class 'django.db.models.query.QuerySet'> >> type(User.objects.all()[:10]) <class 'django.db.models.query.QuerySet'> >> >> type(User.objects.none()) <class 'django.db.models.query.EmptyQuerySet'> >> type(User.objects.none()[:0]) <type 'list'> >> type(User.objects.none()[:10]) <type 'list'>
Change History (2)
comment:1 by , 13 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Type: | Uncategorized → Bug |
comment:2 by , 13 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
nevermind. just discovered this is a dupe of #10139