質問

im用django-登録、すべては、確認メールを送信したテキストがかim固定では、htmlにしてゴミの問題...htmlのコードは:

<a href="http://www.example.com/accounts/activate/46656b86eefc490baf4170134429d83068642139/">http://www. example.com/accounts/activate/46656b86eefc490baf4170134429d83068642139/</a>

やっ必要なものは、htmlコードのように---

ずっと面白いアイデアないか?

感謝

役に立ちましたか?

解決

私は、テキスト版とHTML版の両方を送信してお勧めします。以下のためのジャンゴ登録のmodels.pyで見てます:

send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [self.user.email])

、代わりに HTTPドキュメントからのような何かを://docs.djangoproject.com/en/dev/topics/email/#sending-alternative-content-typesする

from django.core.mail import EmailMultiAlternatives

subject, from_email, to = 'hello', 'from@example.com', 'to@example.com'
text_content = 'This is an important message.'
html_content = '<p>This is an <strong>important</strong> message.</p>'
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send()

他のヒント

避け継ぎdjango登録すのRegistrationProfileモデル 代=True:

models.py

class HtmlRegistrationProfile(RegistrationProfile):
    class Meta:
        proxy = True
    def send_activation_email(self, site):
        """Send the activation mail"""
        from django.core.mail import EmailMultiAlternatives
        from django.template.loader import render_to_string

        ctx_dict = {'activation_key': self.activation_key,
                    'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS,
                    'site': site}
        subject = render_to_string('registration/activation_email_subject.txt',
                                   ctx_dict)
        # Email subject *must not* contain newlines
        subject = ''.join(subject.splitlines())

        message_text = render_to_string('registration/activation_email.txt', ctx_dict)
        message_html = render_to_string('registration/activation_email.html', ctx_dict)

        msg = EmailMultiAlternatives(subject, message_text, settings.DEFAULT_FROM_EMAIL, [self.user.email])
        msg.attach_alternative(message_html, "text/html")
        msg.send()

ご登録をバックエンドで使用 HtmlRegistrationProfile の代わりに RegistrationProfile.

私は、これは古いです知っていないと登録パッケージはもはや維持されています。念のために誰かが、まだこれを望んでいます。 @bpierreの答えに追加の手順WRTは、以下のとおりです。
  - サブクラスRegistrationView、すなわち、アプリケーションのviews.py

class MyRegistrationView(RegistrationView):
...
def register(self, request, **cleaned_data):
    ...
    new_user = HtmlRegistrationProfile.objects.create_inactive_user(username, email, password, site)

- あなたのurls.pyに、すなわち、サブ分類ビューに表示を変更   - リストの項目

url(r'accounts/register/$', MyRegistrationView.as_view(form_class=RegistrationForm), name='registration_register'),'

内容はこちらからご確認くださいdefaultBackend 能を追加するHTMLバージョンの活性化に送いたします。

具体的には、代替版仕事 こちらの

を管理しているバックエンド部に成功し

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top