I have a periodic celery task which is not creating my model
@periodic_task(run_every=timedelta(seconds=1))
def store_products():
products = get_products()
for product in products:
Product.objects.create(
name=product['name'],
description=product['body_html'],
vendor=product['vendor'],
rank=product['rank'],
source=product['source'],
price=product['variants'][0]['price'],
product_id=product['id'],
)
My question is what could I be doing wrong
Due to low reputation i cannot comment. But this might help - Since this is a periodic task 'transaction.atomic' or having 'ISOLATION_LEVEL_SERIALIZABLE' will only create a problem if you are creating objects in multiple child process via celery.
Not much can be concluded from the info provided, but the problems seems in
if you are fetching some data from models without using primary keys in it, it will create a problem.