Skip to content

Commit cf5740f

Browse files
mhinderytimgraham
authored andcommitted
Clarified Concat example in docs.
1 parent 71d3957 commit cf5740f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

docs/ref/models/database-functions.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ Usage examples::
8888
Accepts a list of at least two text fields or expressions and returns the
8989
concatenated text. Each argument must be of a text or char type. If you want
9090
to concatenate a ``TextField()`` with a ``CharField()``, then be sure to tell
91-
Django that the ``output_field`` should be a ``TextField()``. This is also
92-
required when concatenating a ``Value`` as in the example below.
91+
Django that the ``output_field`` should be a ``TextField()``. Specifying an
92+
``output_field`` is also required when concatenating a ``Value`` as in the
93+
example below.
9394

9495
This function will never have a null result. On backends where a null argument
9596
results in the entire expression being null, Django will ensure that each null
@@ -102,8 +103,11 @@ Usage example::
102103
>>> from django.db.models.functions import Concat
103104
>>> Author.objects.create(name='Margaret Smith', goes_by='Maggie')
104105
>>> author = Author.objects.annotate(
105-
... screen_name=Concat('name', V(' ('), 'goes_by', V(')'),
106-
... output_field=CharField())).get()
106+
... screen_name=Concat(
107+
... 'name', V(' ('), 'goes_by', V(')'),
108+
... output_field=CharField()
109+
... )
110+
... ).get()
107111
>>> print(author.screen_name)
108112
Margaret Smith (Maggie)
109113

0 commit comments

Comments
 (0)