當我運行在管理網站上的這個動作(發送電子郵件給選定的人),我有錯誤:Django。 「字符串索引必須是整數,不是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, '[email protected]'
[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)
發佈堆棧跟蹤。 –