def handle(self, *args, **options):
model_name = options.get('model')
from_field = options.get('from_field')
to_field = options.get('to_field')
if not model_name:
raise CommandError('--model_name is a required argument')
if not from_field:
raise CommandError('--from_field is a required argument')
if not to_field:
raise CommandError('--to_field is a required argument')
model = apps.get_model(model_name)
content_type = ContentType.objects.get_for_model(model)
field_histories = FieldHistory.objects.filter(content_type=content_type, field_name=from_field)
self.stdout.write('Updating {} FieldHistory object(s)\n'.format(field_histories.count()))
field_histories.update(field_name=to_field)
renamefieldhistory.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录