On Sat, 2007-11-03 at 11:41 +0000, omat wrote:
> Hi All,
>
> I have a function that sends mail to managers every time a new tag is
> created, connected to post_save of a Tag model via dispatcher.
>
> def mail_new_tag(instance):
> t = loader.get_template('app/new_tag_email.txt')
> c = Context({'tag': instance})
> msg = t.render(c)
> sbj = u'new tag: %s' % (instance.name)
> mail_managers(subject=sbj, message=msg)
>
> This works fine when the instance.name is all ascii, but when it
> contains non-ascii characters, a UnicodeDecodeError is raised.
>
> When debugging, I see that instance.name is a unicode object, but,
> "sbj" cannot be rendered.
Where is it raising the exception? Which line of code in particular. You
should be able to pass Unicode objects to the mail code (in fact, in
[1], I do just that for pretty much all the fields -- that was generated
using Django's email code).
Reading the code, I can't see anything special about mail_managers()
that would cause problems. So if you can past the full traceback that
will probably help work out what might be going on.
Also, what is repr(sbj) just before you call mail_managers()?
[1] http://www.flickr.com/photos/malcolmtredinnick/503502258/
Regards,
Malcolm
--
The early bird may get the worm, but the second mouse gets the cheese.
http://www.pointy-stick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---