当我在管理站点中运行此操作(向选定的人发送电子邮件)时出现错误:
字符串索引必须是整数,而不是 unicode django在线:[p.user_email])
如何解决?
from django.contrib import admin
from myproject.myapp.models import People
from django.core.mail import send_mail
def send_mail(modeladmin, request, queryset):
for p in queryset:
send_mail('People information', p.name, p.time, 'mymail@gmail.com'
[p.user_email])
send_mail.short_description = u'Send e-mail to selected people'
class PeopleAdmin(admin.ModelAdmin):
list_display = ('name', 'user_email','time')
actions = [send_mail]
admin.site.register(People, PeopleAdmin)