Django-fr

Forum

#1 30-11-2011 14:23:48

ael666
Membre
Inscription : 22-11-2011
Messages : 15

relation de table oracle sous django

bonjour,

je debute avec la framework django et en python , mon projet est composé de 5 tables créer sur un schéma oracle

class ESPECE (models.Model):
    ID = models.AutoField(null=False,blank=True,primary_key=True)
    TYPO = models.CharField (max_length=25, blank=False)
    HABITAT = models.CharField (max_length=35, blank=False)
    NOM_CITE = models.CharField (max_length=255,null=True, blank=True)
    LB_NOM = models.CharField(max_length=255,null=True, blank=True)
    TYPE = models.CharField(max_length=255,null=True, blank=True)
    CD_NOM = models.CharField(max_length=255)
    NOM_COMPLET =  models.CharField(max_length=255,null=True, blank=True)

    def __unicode__(self):
        return self.LB_NOM
    
    class Meta :
        db_table = 'ESPECE'

class TYPO_BARCELONE (models.Model):
    ID = models.AutoField(null=False, blank=True,primary_key=True)
    CLE_TRI = models.IntegerField(null=True, blank=True)
    CD_HAB = models.CharField (max_length=25,primary_key=True)
    CD_HAB_SUP = models.CharField (max_length=25)
    LB_HABDH_UK = models.CharField (max_length=255)
    NIVEAU = models.IntegerField (null=True, blank=True)
    LB_DESCRI = models.CharField (max_length=255,blank=True)

    def __unicode__(self):
        return self.CD_HAB
    
    class Meta :
        db_table = 'TYPO_BARCELONE'
    

    
class TYPO_CH (models.Model):
    ID = models.AutoField(null=False, blank=True,primary_key=True)
    CD_HAB = models.CharField (max_length=25,primary_key=True)
    CD_HAB_SUP = models.CharField (max_length=25)
    NIVEAU = models.IntegerField (null=True, blank=True)
    LB_NIVEAU = models.CharField (max_length=50)
    FRANCE = models.CharField (max_length=6,blank=True)
    LB_DESCRI = models.CharField (max_length=255,blank=True)
    LB_CH_EN = models.CharField (max_length=255,blank=True)
    LB_TOME_CH = models.CharField (max_length=10,blank=True)
    CRSP_CB_SELON_CH_PUBLIES = models.CharField (max_length=100,blank=True)
    CORR_CB = models.CharField (max_length=10,blank=True)
    CLE_TRI = models.IntegerField(null=True, blank=True)
    CRSP_CB_SELON_CH = models.CharField (max_length=100,blank=True)
    REMARQUES_CORR_CB = models.CharField (max_length=255,blank=True)

    def __unicode__(self):
        return self.CD_HAB

    class Meta :
        db_table = 'TYPO_CH'


class TYPO_EUNIS_2008 (models.Model):
    ID = models.AutoField(null=False, blank=True,primary_key=True)
    CD_HAB = models.CharField (max_length=25)
    CD_HAB_SUP = models.CharField (max_length=25)
    NIVEAU = models.IntegerField (null=True, blank=True)
    LB_NIVEAU = models.CharField (max_length=50)
    FRANCE = models.CharField (max_length=6)
    LB_EUNIS_FR = models.CharField (max_length=255,blank=True)
    LB_DESCRI = models.CharField (max_length=1000,blank=True)
    LB_DESCRI_EN = models.CharField (max_length=1000,blank=True)
    NOTE = models.CharField (max_length=1000,blank=True)
    REFCD = models.CharField (max_length = 10,blank=True)
    
    def __unicode__(self):
        return self.CD_HAB

    class Meta :
        db_table = 'TYPO_EUNIS_2008'


class TYPO_ZNIEFF_Dauvin_94 (models.Model):
    ID = models.AutoField(null=False, blank=True,primary_key=True)
    CD_HAB = models.CharField (max_length=25)
    CD_HAB_SUP = models.CharField (max_length=25)
    NIVEAU = models.IntegerField (null=True, blank=True)
    LB_DESCRI = models.CharField (max_length=255)
    commentaire_milieu = models.CharField (max_length=1000,blank=True)
    commentaire_biogeographie = models.CharField (max_length=1000,blank=True)
    rq_biocenoses = models.CharField (max_length=1000,blank=True)

    def __unicode__(self):
        return self.CD_HAB

    class Meta :
        db_table = 'TYPO_ZNIEFF_Dauvin_94'



class TYPO_BBMEDFR (models.Model):
    ID = models.AutoField(null=False, blank=True,primary_key=True)
    CD_HAB = models.CharField (max_length=25)
    CD_HAB_SUP = models.CharField (max_length=25)
    NIVEAU = models.IntegerField (null=True, blank=True)
    LB_NIVEAU = models.CharField (max_length=25)
    LB_DESCRI = models.CharField (max_length=255,blank=True)
    FRANCE = models.CharField (max_length=6,blank=True)
    LB_BBMEDFR_EN = models.CharField (max_length=1000,blank=True)
    CLE_TRI = models.IntegerField(null=True, blank=True)

    def __unicode__(self):
        return self.CD_HAB

    class Meta :
        db_table = 'TYPO_BBMEDFR'

chaque table typo a une relation de 1>>cd_hab (typo) à n>> habitats (espece) avec la table espece
Si j'ai bien compris il faudrait que je crée sur espece un champs avec un type models.ForeignKey et un autre models.ManyToManyField mais sur tout les exemples que je vois on indique la table entre parenthése hors cette table est en relation avec les quatres table typo....
bref je suis un peu perdu...

merci de m'éclairer

Hors ligne

Pied de page des forums