我已经将我的django项目连接到带有api和LIST KEY的mailchimp列表以获取信号。现在我愿意为此函数添加一个额外的列表但是它似乎不能用逗号分隔.Should我复制功能更改参数还是有一种更简单的方法?感谢
class Newsletter (models.Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL)
active = models.BooleanField (default =True)
def __str__(self):
if self.active:
return 'Subscribed'
else:
return 'Unsubscribed'
def update_newsletter (sender, instance, **kwargs):
print (instance.user)
m = get_mailchimp_api()
email = {'email': instance.user.email}
if not instance.active:
m.lists.unsubscribe('**LIST_ID**', email ,
delete_member= False)
else:
m.lists.subscribe('**LIST_ID**', email ,
double_optin= False,
update_existing = False,
send_welcome = False)
post_save.connect (update_newsletter, sender = Newsletter)