AttributeError | 'Template' object has no attribute 'render'

1,184 views
Skip to first unread message

Nakaya Mitsuo

unread,
Nov 4, 2014, 9:25:27 PM11/4/14
to django...@googlegroups.com
I got AttributeError.
Exception Value: 'Template' object has no attribute 'render'

How can I fix it?
Please help me.

------- CODE ------

from django.shortcuts import render
from django.template import Context, Template

class US_AccountManager(models.Manager):
   def update_account(self, auth_user, email):
       us_profile = auth_user.us_profile
       if auth_user.email == email:
           pass
       else:
           try:
               mail_template = Mail_Template.objects.get(position = 'MC')
               context = Context({'site_root':site_root,
                   'app_name':app_name})
               message = Template(mail_template.message).render(context)
               subject = mail_template.subject
               send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [auth_user.email])
           except Mail_Template.DoesNotExist:
               try:
                   send_mail_dict = {'site_root':site_root,
                   'app_name':app_name}
                   subject = 'From' + app_name
                   message = render_to_string('txt/change_email.txt',send_mail_dict)
                   send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [auth_user.email])
               except:
                   pass
       return auth_user

I want to send mail from template ( contain in database ).
And render the template.

Sorry my poor English.

Nakaya Mitsuo

unread,
Nov 8, 2014, 11:22:07 AM11/8/14
to django...@googlegroups.com
It resolved.

I used "Template" in Database.
It was the cause.
It was a simple mistake.


Thank you.


2014年11月5日水曜日 11時25分27秒 UTC+9 Nakaya Mitsuo:
Reply all
Reply to author
Forward
0 new messages