I have a loop like this:
def handle(self, *args, **options):
database.objects.all().delete()
for x in list:
db.objects.create(
...add some data to database table...)
The list consists of 100 values. But I may run the loop with only 30 values at a time. And it's needed to have run all 100 values for the end of the script.
Why I have such a weird question, is that the script takes data from a third-party database, but it is allowed to take 30 objects at a time. So what I need is the script to take 30 values. Somehow pause and take the next 30 values and on the last time, take the 10 values, that are left and finishes.
Is something like this possible, or do I need to make my list into many small lists and run them one at a time?