We're a place where coders share, stay up-to-date and grow their careers.
Hey, first of all thanks for sharing!
I'm trying to populate my database using a Data Migration.
In my populate function I have 2 api calls, so the shape is something like this:
async def populate_table(apps, schema_editor): some stuff... an api call like: await get_info()... an api call inside a for loop (any problem with this?) for i in range(): an api call like: await get_another_info()... more stuff... model.save()
And then, I have my migration class:
class Migration(migrations.Migration): dependencies = [ ('app', 'the previous migration'), ] operations = [ migrations.RunPython(populate_table) ]
Running the migration a Runtime Warning is raised:
RuntimeWarning: coroutine 'populate_table' was never awaited
So I try to decorate my Migration with Async Await without success.
How should I do that? And again, any problem to have async tasks inside a sync for loop?
Hey, first of all thanks for sharing!
I'm trying to populate my database using a Data Migration.
In my populate function I have 2 api calls, so the shape is something like this:
And then, I have my migration class:
Running the migration a Runtime Warning is raised:
So I try to decorate my Migration with Async Await without success.
How should I do that? And again, any problem to have async tasks inside a sync for loop?