while min < rowcount:
    min += 500
max = min + 500
articles = Article.objects.raw(
    'SELECT * from article where id > %s and id < %s' % (min, max))
for old_article in articles:
    article.save()
Efficient data migration on a large django table