I'm trying to create a cronjob in django using faust. If I create a simple cronjob printing somethin' on screen it works, but if I try to use some ORM thing it doesn't.
@sync_to_async
def get_products():
return Product.objects.filter(active=True)
@app.crontab('* * * * *')
async def run_very_minute():
product = await get_products()
print(product)
I also tried to do like this:
@app.crontab('* * * * *')
async def run_very_minute():
products = await sync_to_async(list)(Product.objects.filter(active=True))
print(product)