Alex Rivera | Logout

How to set the language in render_to_string helper?

Asked 2010-12-27T14:35:25.470
10

From a save signal in Django I want to send an e-mail. The language of the email should be set based on the content being saved (it has a lang flag). How can I pass that language to Djangos render_to_string helper? I can only find language settings for RequestContexts, and there is no request or user available here.

Sincerely Björn

Edit
Report

1 Answer

1

It appears as I can use translation.activate(some_lang) before every message I send. I'm not sure if this is efficient or not.

I see that it's possible to send a Context instance to render_to_string. If I can place the language setting in that context somehow, it would be nice.

answered 2010-12-27T15:39:18.720

Your Answer