def create_types(clear=True): from awesome.models import ExerciseType if clear: ExerciseType.collection.remove({}) for type_ in types: exercise = ExerciseType(**type_) exercise.save()