def manage_categorie(self, loisir): text = self.get_node_text(loisir, self.categorie_key) if text is not None: if Categorie.objects.filter(UID=text).count() == 0: model = Categorie() model.UID = text model.save() pprint(model)
parser = LoisirParser("LOISIR_PAYANT") else: print "bad" exit() loisirs = parser.parse( f.read() ) category_parser = CategoryParser() categories = category_parser.categorie_loisirs(loisirs) for c in categories: if c is not None and Categorie.objects.filter(UID=c).count() == 0: model = Categorie() model.UID = c model.save() print c for l in loisirs: L = Loisir() L.CODE_SESSION = l['code_session'] L.DESCRIPTION = l['description'] L.DESCRIPTION_ACT = l['act'] L.DESCRIPTION_NAT = l['nat'] L.NOM_COUR = l['cours'] L.ARRONDISSEMENT = l['arrondissement'] L.ADRESSE = l['adresse'] L.CATEGORIE = Categorie.objects.get(UID=l['nat']) if len(l['lieux']) > 0: