class patient(models.Model):
choix = (
(0, 0),
(1, 1),
(0.1, 0.1),
(0.15, 0.15),
(0.2, 0.2),
(0.25, 0.25),
(0.3, 0.3),
(0.4, 0.4),
(0.5, 0.5),
(0.6, 0.6),
(0.7, 0.7),
(0.8, 0.8),
(0.9, 0.9),
)
date_creation=models.DateField(auto_now_add=True,null=True)
Nom_patient=models.CharField(max_length=200,null=True)
date_naissance=models.DateField(max_length=200,null=True)
numero_telephone=models.CharField(max_length=30, null=True)
adresse=models.CharField(max_length=100, null=True)
matricule=models.CharField(max_length=200,default="Pas de matricule",null=True)
assurance=models.CharField(max_length=200,default="Non assuré",null=True)
compagnie=models.CharField(max_length=200,default="Pas de compagnie",null=True)
medecin=models.CharField(max_length=200,null=True)
pourcentage = models.FloatField(max_length=20,default='Pas de pourcentage',null=True, choices=choix)
def __str__(self):
return self.Nom_patient
class labo(models.Model):
patient=models.ForeignKey(patient, null=True, on_delete=models.SET_NULL,related_name='labos')
def __str__(self):
return self.libelle_labo
class specialite(models.Model):
patient=models.ForeignKey(patient, null=True, on_delete=models.SET_NULL,related_name='specialistes')
class generalister(models.Model):
patient = models.ForeignKey(patient, null=True, on_delete=models.SET_NULL,related_name='generalisters')
def __str__(self):
return self.libelle_generaliste
When posting code here, please enclose it between lines consisting of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```.
Also, what is your question or issue with this post? What have you tried that is not working or throwing an error?
OK, thank you very much
The problem is that I can’t keep track of all of a patient’s procedures.
and this is my recovery code
def recu(request):
affichepatient=patient.objects.prefetch_related('labos','specialistes','generalisters').all()
context={'affichepatient':affichepatient}
return render(request,'recu/recu.html',context)
I am having difficulty retrieving a patient’s records.
You need to be a lot more specific here. Please describe in detail what you’re expecting to have happen, and what’s actually happening. If you’re getting a traceback, please post the complete traceback. If not, describe the results you are getting.