About Adding Non-numeric List Items Together

You can add non-numeric list items together with the reduce function, e.g.:

1
2
3
4
5
6
7
8
from functools import reduce
import operator
from django.contrib.postgres.search import SearchVector

# dynamically set up list
vectors = [SearchVector(...), SearchVector(...), SearchVector(...)]
# add the vectors together
vector = reduce(operator.add, vectors)

Tips and Tricks Programming Django 5.x Django 4.2 Django 3.2 Python 3