Django+使用 django-registration 以 html 格式发送电子邮件
我使用 django-registration,一切都很好,确认电子邮件以纯文本形式发送,但知道我已修复并以 html 形式发送,但我有一个垃圾问题... html 代码正在显示:
<a href="http://www.example.com/accounts/activate/46656b86eefc490baf4170134429d83068642139/">http://www. example.com/accounts/activate/46656b86eefc490baf4170134429d83068642139/</a>
并且我不需要显示html 代码就像...
有什么想法吗?
谢谢
im using django-registration, all is fine, the confirmation email was sending in plain text, but know im fixed and is sending in html, but i have a litter problem... the html code is showing:
<a href="http://www.example.com/accounts/activate/46656b86eefc490baf4170134429d83068642139/">http://www. example.com/accounts/activate/46656b86eefc490baf4170134429d83068642139/</a>
and i dont need to show the html code like the ...
Any idea?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为了避免修补 django-registration,您应该使用 扩展 RegistrationProfile 模型proxy=True:
models.py
在您的注册后端中,只需使用 HtmlRegistrationProfile 而不是 RegistrationProfile。
To avoid patching django-registration, you should extend the RegistrationProfile model with proxy=True:
models.py
And in your registration backend, just use HtmlRegistrationProfile instead of RegistrationProfile.
我建议同时发送文本版本和 html 版本。在 django-registration 的 models.py 中查找 : ,
然后执行类似文档 http://docs.djangoproject.com/en/dev/topics/email/#sending-alternative-content-types
I'd recommend sending both a text version and an html version. Look in the models.py of the django-registration for :
and instead do something like from the docs http://docs.djangoproject.com/en/dev/topics/email/#sending-alternative-content-types
我知道这是旧的并且不再维护注册包。以防万一有人还想要这个。
回答 @bpierre 的附加步骤是:
- 对 RegistrationView 进行子类化,即您应用程序的views.py
- 在您的 urls.py 中将视图更改为子类视图,即
- 列表项
I know this is old and the registration package is no longer maintained. Just in case somebody still wants this.
The additional steps wrt to the answer of @bpierre are:
- subclass the RegistrationView, i.e. your app's views.py
- in your urls.py change the view to the sub-classed view, i.e.
- List item
此人扩展了 defaultBackend,使我们能够添加 HTML 版本的激活电子邮件。
具体来说,备用版本作业已完成 这里
我成功地使用了后端部分
This guy have extended the defaultBackend enabling us to add an HTML version of the activation email.
Specifically, the alternate version job is done here
I managed to use the backend part successfully