[Django] #34199: Add documentation for contrib.postgres.aggregates.StringAgg

8 views
Skip to first unread message

Django

unread,
Dec 3, 2022, 6:21:33 AM12/3/22
to django-...@googlegroups.com
#34199: Add documentation for contrib.postgres.aggregates.StringAgg
-------------------------------------+-------------------------------------
Reporter: Mark | Owner: Mark Gensler
Gensler |
Type: | Status: assigned
Uncategorized |
Component: | Version: dev
Documentation |
Severity: Normal | Keywords: postgres StringAgg
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
The documentation is missing an example for StringAgg. Also I thought it
would be useful to include an example for ManyToMany fields, in contrast
to the OneToMany example for JSONBAgg.

I.e.
{{{#!python
class Publication(models.Model):
title = models.CharField(max_length=30)

class Article(model.Model):
headline = models.CharField(max_length=100)
publications = models.ManyToManyField(Publication)

>>> article = Article.objects.create(headline='NASA uses Python')
>>> article.publications.create(title='The Python Journal')
>>> article.publications.create(title='Science News')

>>> from django.contrib.postgres.aggregates import StringAgg
>>> Article.objects.annotate(
... publication_names=StringAgg(
... 'publications__title',
... delimiter=', ',
... ordering='publications__title',
... )
... ).values('headline', 'publication_names')
<QuerySet [{
'headline': 'NASA uses Python', 'publication_names': 'Science News,
The Python Journal'
]}]>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34199>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 3, 2022, 6:28:23 AM12/3/22
to django-...@googlegroups.com
#34199: Add documentation for contrib.postgres.aggregates.StringAgg
-------------------------------------+-------------------------------------
Reporter: Mark Gensler | Owner: Mark
| Gensler
Type: Uncategorized | Status: assigned
Component: Documentation | Version: dev
Severity: Normal | Resolution:

Keywords: postgres StringAgg | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mark Gensler):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34199#comment:1>

Django

unread,
Dec 3, 2022, 9:49:42 AM12/3/22
to django-...@googlegroups.com
#34199: Add documentation for contrib.postgres.aggregates.StringAgg
-------------------------------------+-------------------------------------
Reporter: Mark Gensler | Owner: Mark
| Gensler
Type: Uncategorized | Status: assigned
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: postgres StringAgg | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by David Sanders):

Hi Mark,

Thanks for the input!

Just FYI you don't need a ticket for trivial documentation updates. I
think an example like this may fall under that category 👍

--
Ticket URL: <https://code.djangoproject.com/ticket/34199#comment:2>

Django

unread,
Dec 3, 2022, 10:29:36 AM12/3/22
to django-...@googlegroups.com
#34199: Add documentation for contrib.postgres.aggregates.StringAgg
-------------------------------------+-------------------------------------
Reporter: Mark Gensler | Owner: Mark
| Gensler
Type: Uncategorized | Status: assigned
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: postgres StringAgg | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mark Gensler):

Hi David, you're welcome! Thanks for letting me know, I will just make a
PR for something like this in future.

Mark

--
Ticket URL: <https://code.djangoproject.com/ticket/34199#comment:3>

Reply all
Reply to author
Forward
0 new messages