def store_to_db(data, extra_attr=None): create = False try: result = ResultData.get(task_id=data["task_id"]) except ResultData.DoesNotExist: create = True if create: result = ResultData() result.transaction_id = data["transaction_id"] result.task_id = data["task_id"] result.task_type = data["test_type"] result.location = data["location"] result.country = data["country"] result.url = data["url"] if extra_attr: result.extra_attr = extra_attr result.task_status = data["status"] # Difference between status and task_status. task_status is for celery task. result.status = str(data["status_code"]) result.raw_data = data result.save()