Ejemplo n.º 1
0
    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:
            L.LIEU_1 = l['lieux'][0]

        if len(l['lieux']) > 1:
            L.LIEU_2 = l['lieux'][1]

        print l
        L.save()