Valueerror: Need More Than 1 Value To Unpack, Django Email Error
I'm trying to use django to send emails to a bunch of people at the same time (although right now, I'm trying to get it to work with only one). I have a class called User that has
Solution 1:
You want to use flat=True
in your values_list
query.
From the docs:
This is similar to values() except that instead of returning dictionaries, it returns tuples when iterated over.
If you only pass in a single field, you can also pass in the flat parameter. If True, this will mean the returned results are single values, rather than one-tuples.
https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list
So rather than a list of addresses, your addresses is an iterator that returns tuples of addresses, which is not what EmailMessage is expecting.
Solution 2:
Found a solution. Very simple, actually.
addresses = User.objects.filter(group__group='Operations').values_list('email', flat=True)
Post a Comment for "Valueerror: Need More Than 1 Value To Unpack, Django Email Error"