型号装备:
class Equipement(models.Model):
nom_equipement=models.CharField(max_length=60)
qte_stock=models.IntegerField()
panne=models.ManyToManyField(Panne)
模型干预:
class Intervention(models.Model):
Titre_intervention = models.TextField(max_length=255)
date_intervention = models.DateField(auto_now_add=True)
type_panne = models.ForeignKey(Panne,on_delete=models.CASCADE)
etat = models.CharField(max_length=30)
description = models.TextField(max_length=255)
image = models.ImageField(blank=True,null=True,upload_to='medial/%Y/%m/%D')
equipements = models.ManyToManyField(Equipement)
clients = models.ForeignKey(Client,on_delete=models.CASCADE,default=True)
建立具有许多关系的干预模型:
因此,当我添加新的“干预”时,它将添加到关联表中
我需要列出每种干预措施的所有设备,这是我的观点:
def mes_intervention(request):
if 'id_client' in request.session:
get_idClient=request.session['id_client']
Interv_client = Intervention.objects.all().filter(clients=get_idClient)
context = {
'intervention':Interv_client
}
return render(request, 'clients/mes-intervention.html',context)
这是我将所有干预内容都列出到模板html中的位置>>
模型设备:类设备(models.Model):nom_equipement =模型.CharField(max_length = 60)qte_stock = models.IntegerField()panne = models.ManyToManyField(Panne)...