def create_loisir(self, loisir): model = Loisir() for field in self.fields: text = self.get_node_text(loisir, field) setattr(model, field, text) text = self.get_node_text(loisir, "TARIF_BASE") print "tarif", text if text is not None: model.TARIF_BASE = decimal.Decimal(text) categorie_name = self.get_node_text(loisir, self.categorie_key) if categorie_name is not None: model.CATEGORIE = Categorie.objects.get(UID=categorie_name) model.save() pprint(model) return model
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: L.LIEU_1 = l['lieux'][0] if len(l['lieux']) > 1: L.LIEU_2 = l['lieux'][1] print l L.save() for h in l['horaires']: H = Horaire() H.LOISIR = (L) H.DATE_DEB = h['date_debut'] H.DATE_FIN = h['date_fin'] H.HEURE_DEBUT = h['heure_debut'] H.HEURE_FIN = h['heure_fin'] H.JOUR_SEMAINE = h['jour'] H.save() pprint( l ) ''' {'act': u'Chant choral - Journ\xe9e portes ouvertes',