Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango-Templated-Email: TemplateDoesNotExist when importing from a different file
    primarykey
    data
    text
    <p>I have a Django project with two apps: email_app and landing_page_app. The <code>landing_page_app.views</code> includes <code>email_app.views</code>, so that it can use the <code>new_lead_email</code> function. </p> <p>In <code>email_app.views</code>:</p> <pre><code>from datetime import datetime from templated_email import send_templated_mail def new_lead_email(email): send_templated_mail( template_name='new_lead', from_email='name@somewhere.com', recipient_list=['name@somewhere.com'], context={ 'email': email, 'current_time': str(datetime.now()), }, ) </code></pre> <p>In <code>landing_page_app.views</code>:</p> <pre><code>from email_app.views import new_lead_email new_lead_email(email) </code></pre> <p>I get a "TemplateDoesNotExist" error for "templated_email/new_lead.txt". The <code>new_lead_email</code> function works correctly when it is not imported into <code>landing_page_app.views</code> (i.e. if I have a Django URL call <code>new_lead_email</code> in <code>email_app.views</code> directly).</p> <p>In settings.py, I set <code>TEMPLATED_EMAIL_TEMPLATE_DIR</code> and <code>TEMPLATED_EMAIL_FILE_EXTENSION</code> to a directory that contains the "new_lead.email" template. This suggests that the vanilla_django.py file in django-templated-email (https://github.com/bradwhittington/django-templated-email/blob/master/templated_email/backends/vanilla_django.py) is not importing my settings.py file correctly. </p> <p>Do you have any suggestions for how to import functions in <code>email_app.views</code> into other files and have the templates work correctly. Thanks to bradwhittington for a VERY useful Django class. I look forward to learning how to use it correctly!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload