sync_responses.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:django-twilio-sms-models 作者: cfc603 项目源码 文件源码
def handle(self, *args, **options):
        if hasattr(settings, 'DJANGO_TWILIO_SMS_RESPONSES'):
            for action in Action.objects.all():
                action.delete()

            for action, response in iteritems(
                    settings.DJANGO_TWILIO_SMS_RESPONSES):
                action = Action.objects.create(name=action)
                response = Response.objects.create(
                    body=response, action=action
                )

                self.stdout.write('CREATED: {}-{}'.format(
                    action.name, response.body
                ))
        else:
            self.stdout.write('No responses found in settings.')

            if Action.objects.all().count() > 0:
                for action in Action.objects.all():
                    action.delete()
                self.stdout.write('All saved responses have been deleted.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号