0

I am trying to give the user the ability to enter data here is my models named cv :

class Experience_Pro(models.Model):
    annee_debut = models.IntegerField()
    annee_fin = models.IntegerField()
    description_exp_pro = models.TextField(null=True,blank=True)

class Ecole(models.Model):
    nom_ecole = models.CharField(max_length=50)
    classement = models.IntegerField()

class Academic(models.Model):
    annee_debut = models.IntegerField()
    annee_fin = models.IntegerField()
    type_diplome = models.CharField(max_length=10)
    description_academic = models.TextField(null=True,blank=True)
    ecole = models.ForeignKey('Ecole' , on_delete=models.DO_NOTHING)

class Cv(models.Model):
    experience_Pro = models.ForeignKey('Experience_Pro' ,on_delete=models.CASCADE)
    academic = models.ForeignKey('Academic',on_delete=models.CASCADE)

and here is my form

class CvForm(forms.ModelForm):
    class Meta: 
        model = Cv     
        fields = "__all__"

but instead of getting inputs for the user to enter data i get a dropdownlist of already existed records in my database.

Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63

2 Answers2

0

Unfortunately, that is the way django is designed when using a ModelForm.

Realistically, you can create two model forms from the Experience & Academic models and join them in the view.

Multiple Models in a single django ModelForm?

Victor 'Chris' Cabral
  • 2,135
  • 1
  • 16
  • 33
0

Your cv model doesnt have any fields for input. You are only have the relation with other model as a foreignkey relation. This way you can only access the data here not create one

ngawang13
  • 663
  • 1
  • 5
  • 12