如何在管理站点中创建特定功能,向人员(电子邮件)发送电子邮件,其中包含来自我的模型的信息(名称、价格)?
像这样,但“向选定的人发送电子邮件”:
模型.py
from django.db import models
class People(models.Model):
name = models.CharField(max_length=255)
price = models.DecimalField(max_digits=5, decimal_places=2)
email = models.EmailField()
def __unicode__(self):
return self.name
管理员.py
from django.contrib import admin
from demo.app.models import People
class PeopleAdmin(admin.ModelAdmin):
list_display = ('name', 'email')
admin.site.register(People, PeopleAdmin)
电子邮件
send_mail('People information', 'People name is People.name, People price is People.price', 'mymail@gmail.com',
['email_from_email_field_from_model'])