brack3t / Djrill

[INACTIVE/UNMAINTAINED] Djrill is an email backend and new message class for Django users that want to take advantage of the Mandrill transactional email service from MailChimp.
BSD 3-Clause "New" or "Revised" License
319 stars 64 forks source link

TypeError: is not JSON serializable #100

Closed Hiieu closed 9 years ago

Hiieu commented 9 years ago
TypeError: <django.utils.functional.__proxy__ object at 0x030B1D30> is not JSON serializable in a Djrill message (perhaps it's a merge var?). Try converting i  t to a string or number first. 

What does it mean?

medmunds commented 9 years ago

The "not JSON serializable" error means one of the options you've set on your EmailMessage is an unexpected type, and Djrill doesn't know how to convert it to something Mandrill will understand. So you'll need to convert it to a string yourself, when you set the option.

This commonly occurs with merge variables, but it could be any option you're setting. (We'd need to see the part of your code that's creating and sending the message to say more.)

django.utils.functional.__proxy__ probably means the issue is with an option being set to a lazy string translation (ugettext_lazy). If that's the problem, you can probably fix it by switching to the non-lazy version of ugettext.

Hiieu commented 9 years ago

Yes that was it, thanks.