Tuesday 15 July 2014

python - ValueError: need more than 1 value to unpack, django email error -


I am trying to use the DNS to send email to a group of people at the same time (though right now I'm trying to work with only one) I have a class named user in which a cell named field email and group To have a foreign key. Now, I am trying to send an email to all users of a particular group. To do this, I have the following code:

addresses = User.objects.filter (group__group = 'Operations'). Values_list ('email')

This is getting the correct email address (if I print addresses me ([u'address @ Example.com ']] . Then I addresses to create an email:

  email = email message (' test ', get_template (' test .html '). Renderer (reference ({{content': 'this one test!'}))) = Addresses from when I was doing this before, manually going through "to" logic from email address , It used to work perfectly, but now it gives me the title in the title Gives: "Value error: Unpacking requires more than 1 value. Line of code that generates error code is  email.send () .  

This What is the meaning of error? Why am I receiving it? How should I fix it? Is there a better way of getting the email addresses of all the users in the specified group?

Thanks.

found a solution very simple, actually In

  addresses = User.objects.filter (group__group = 'Operations'). Values_list ('email', flat = true)    

No comments:

Post a Comment