سؤال

I'm writing a Django 1.4 app that will send HTML email. I'm using Django templates to render the email content, but I'm unsure how to store the templates.

I can store them in an email app (like I would other templates), but it feels silly to use a static file.

I thought about creating an Email model and storing the template code as a TextField, which would work.

I searched for better solutions and saw sendwithus.com on reddit, which is a neat idea...

Is there a Django convention for this sort of thing?

هل كانت مفيدة؟

المحلول

The general approach is to store email templates either globally in the project template folder or in the template folder of your email app. If you build a reusable app you can provide examples of email templates in your apps template folder, but make it possible to overwrite them via global project template (prioritize project templates before app templates in TEMPLATE_READERS, usually the default in django).

I think you other ideas are overkill for something so simple.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top