Python satchmo mail.py发送html电子邮件而不是文本电子邮件

Python satchmo mail.py发送html电子邮件而不是文本电子邮件,python,django,registration,satchmo,Python,Django,Registration,Satchmo,对于我目前的satchmo商店,我想发送html电子邮件,而不是所有的txt电子邮件。从satchmo_商店帐户注册码的外观来看,所有电子邮件都是硬编码的,并且使用.txt格式而不是html格式。 e、 g.mail.py """Sends mail related to accounts.""" from django.conf import settings from django.utils.translation import ugettext from satchmo_store.m

对于我目前的satchmo商店,我想发送html电子邮件,而不是所有的txt电子邮件。从satchmo_商店帐户注册码的外观来看,所有电子邮件都是硬编码的,并且使用.txt格式而不是html格式。 e、 g.mail.py

"""Sends mail related to accounts."""

from django.conf import settings
from django.utils.translation import ugettext
from satchmo_store.mail import send_store_mail
from satchmo_store.shop.models import Config
from satchmo_store.shop.signals import registration_sender

import logging
log = logging.getLogger('satchmo_store.accounts.mail')

# TODO add html email template
def send_welcome_email(email, first_name, last_name):
    """Send a store new account welcome mail to `email`."""

    shop_config = Config.objects.get_current()
    subject = ugettext("Welcome to %(shop_name)s")
    c = {
        'first_name': first_name,
        'last_name': last_name,
        'site_url': shop_config.site and shop_config.site.domain or 'localhost',
        'login_url': settings.LOGIN_URL,
    }
    send_store_mail(subject, c, 'registration/welcome.txt', [email],
                    format_subject=True, sender=registration_sender)
我知道您可以将最后一行更改为以下内容以使其正常工作:

send_store_mail(
    subject=subject,
    context=c,
    template='registration/welcome.txt',
    recipients_list=[email],
    format_subject=True,
    sender=registration_sender,
    template_html='registration/welcome.html')
然而,在不久的将来,为了升级的目的,我最好不要接触Satchmo应用程序中的代码

是否有人知道,在不接触satchmo应用程序的情况下,覆盖此功能或为所有注册相关功能启用html电子邮件的理想方式是什么


提前感谢。

我已通过以下方式对Satchmo内部进行了类似的更改:

应该可以将Satchmo安装中的相关文件复制到django应用程序中。如果您根据设置Satchmo商店,则可能意味着将Satchmo/apps/Satchmo_store/accounts/mail.py复制到/localsite/accounts/mail.py。其思想是自动加载本地副本而不是原始副本

在mail.py的本地副本中,可以替换send\u store\u email()函数。记下备忘,以便在Satchmo升级时记住所做的更改。很有可能原始文件仍然是相同的,并且您的覆盖即使在将来的版本中也会起作用


在其他情况下,当您必须更改某些类行为时,您还可以使用一个仅更改相关方法的子类来对原始类进行子类化,同时保留原始名称。

我已通过以下方式对Satchmo内部进行了类似的更改:

应该可以将Satchmo安装中的相关文件复制到django应用程序中。如果您根据设置Satchmo商店,则可能意味着将Satchmo/apps/Satchmo_store/accounts/mail.py复制到/localsite/accounts/mail.py。其思想是自动加载本地副本而不是原始副本

在mail.py的本地副本中,可以替换send\u store\u email()函数。记下备忘,以便在Satchmo升级时记住所做的更改。很有可能原始文件仍然是相同的,并且您的覆盖即使在将来的版本中也会起作用


在其他情况下,当您必须更改某些类的行为时,您还可以使用一个只更改相关方法的子类对原始类进行分类,同时保留原始名称。

谢谢,bwell。我设法为register函数创建了view.py、form.py和mail.py的本地副本,并为register函数添加了url的替换项,效果非常好。我想我只需要确保在以后的升级中注意到这一点,所以我以后必须手动更新本地注册功能。再次感谢。谢谢你,贝尔。我设法为register函数创建了view.py、form.py和mail.py的本地副本,并为register函数添加了url的替换项,效果非常好。我想我只需要确保在以后的升级中注意到这一点,所以我以后必须手动更新本地注册功能。再次感谢。