Django autofill inlineformset_factory

first of all ,i'm start usin django a few mounth ago also i'm not good using english language so sorry in the first place i've create models like this

class Project(models.Model):
    def __str__(self):
        return self.name
    
    name=models.CharField(max_length=80)
class champs(models.Model):
    def __str__(self):
        return self.nom
    def ImageSet(instance,nom):
        return """/project_manager/static/projects/{}_{}""".format(instance.id,nom)
    name=models.CharField(max_length=50,unique=True)
    ordre=models.IntegerField(default=999)
    illustration=models.ImageField(upload_to=ImageSet, height_field=None, width_field=None, max_length=None,blank=True,null=True)
    parent=models.ForeignKey(Project, verbose_name="projet", on_delete=models.CASCADE)
class commade(models.Model):
    def __str__(self):
        return self.description
    
    clientFirstName=models.CharField(max_length=50)
    clientLastName=models.CharField(max_length=50)
    addres=models.CharField(verbose_name="adresse de l'intervention", max_length=300)
    email=models.EmailField(max_length=254)
    tel=PhoneNumberField(blank=True)
    date_d_intervention=models.DateTimeField(auto_now=False, auto_now_add=False,verbose_name="date d'intervention")
    project = models.ForeignKey(Project, on_delete=models.CASCADE)
    description=models.TextField()
class Response(models.Model):
    def __str__(self):
        return self.champs.name
    commande=models.ForeignKey(commade, on_delete=models.CASCADE)
    champs=models.ForeignKey(champs, on_delete=models.CASCADE)
    valeur=models.CharField( max_length=80)
    
    

i've create django admin were i can autofill inlineformset of response model champs with values of which have the same project before i choose the project when i chose the project now what i need is how to make it using inlineformset_factory in django forms.py or usin views.py without using js or jquery for security purpos can you teach me please thanks in advence

Back to Top