Пример #1
0
 def _load_children(self):
     """
     LOAD CHILDREN
     :return: Nothing. Happens in place
     """
     self.stdout.write('\nloading children')
     self.children_data['sex'] = self.children_data['sex'].str.lower()
     self.children_data['sex'].fillna('m', inplace=True)  # set them all to 'male'. This can be cleaned up later
     self.children_lookup = {}
     failing_children = {}
     for child_data in self.children_data.to_dict(orient='records'):
         self.stdout.write('.', ending="")
         self.stdout.flush()
         child = Child(**child_data)
         try:
             child.full_clean()
             child.save()
             self.children_lookup[child.id] = child
         except ValidationError as e:
             failing_children[str(child)] = e
     if failing_children:
         raise CommandError('Children failed validation:\n{0}'.format(pprint.pformat(failing_children, indent=4)))