|
@@ -9,6 +9,7 @@ from tempfile import NamedTemporaryFile
|
|
|
from django.conf import settings
|
|
|
from django.template import loader, Context
|
|
|
from django.core.files import File
|
|
|
+from django.utils import translation
|
|
|
|
|
|
|
|
|
def link_callback(uri, rel):
|
|
@@ -51,6 +52,9 @@ def render_as_pdf(template, context):
|
|
|
converti en PDF via le module xhtml2pdf.
|
|
|
Renvoi un objet de type File
|
|
|
"""
|
|
|
+ # Force locale, because isn't done when launched from managment command
|
|
|
+ translation.activate(settings.LANGUAGE_CODE)
|
|
|
+
|
|
|
template = loader.get_template(template)
|
|
|
html = template.render(Context(context))
|
|
|
file = NamedTemporaryFile()
|