Beispiel #1
0
def csv2model(csv_line):
    todo = Todo(
        todo_title=csv_line['todo_title'],
        todo_status=csv_line['todo_status'],
        todo_user=User.objects.get(pk=csv_line['todo_user']),
        created_at=csv_line['created_at'],
        created_by=User.objects.get(pk=csv_line['created_by']),
        updated_by=User.objects.get(pk=csv_line['updated_by']),
    )
    try:
        todo.full_clean()
    except ValidationError as e:
        print('error in Validation model', e)
        return False
    else:
        todo.save()
        return True