#30817: Document that Sitemap.items can return a QuerySet
------------------------------------------------+-------------------------
Reporter: Chris Jerdonek | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: master
Severity: Normal | Keywords: sitemap
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
------------------------------------------------+-------------------------
Currently, the Django docs don't say that `Sitemap.items()` can return a
`QuerySet`. It just says it can return a list:
> Sitemap.items: Required. A method that returns a list of objects.
(From:
https://github.com/django/django/blob/fa8fe09e4e2b538c5d50a559081861d5c0635d55/docs/ref/contrib/sitemaps.txt#L136-L142
)
> :attr:`~Sitemap.items()` is a method that returns a list of objects.
(From:
https://github.com/django/django/blob/fa8fe09e4e2b538c5d50a559081861d5c0635d55/docs/ref/contrib/sitemaps.txt#L119
)
We know it can be a `QuerySet` because e.g. the items are passed to a
`Paginator`:
https://github.com/django/django/blob/fa8fe09e4e2b538c5d50a559081861d5c0635d55/django/contrib/sitemaps/__init__.py#L80
and `Paginator` objects accept `QuerySet` objects:
https://docs.djangoproject.com/en/2.2/topics/pagination/#example
Knowing that it can return a `QuerySet` is useful if you want to paginate
your sitemap without having to temporarily query and store in memory all
objects in one (possibly giant) list.
--
Ticket URL: <https://code.djangoproject.com/ticket/30817>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.09a23a64cacff4de8ae7ac78a20f21c2%40djangoproject.com.