0
所以我用Django框架建立這個網站:gegeneo.pythonanywhere.com如何關聯表,並查看它們
我有兩個表患者和診斷:
病人:
class Patient(models.Model):
PatientName = models.CharField(max_length = 120);
PatientBirthDate = models.DateField();
PatientInitialWeight = models.PositiveIntegerField();
PatientBloodGroup = models.CharField(max_length = 4);
Patient_Booking_Date = models.DateTimeField(auto_now = False, auto_now_add = True);
def __str__(self):
return self.PatientName;
診斷:
class Diagnosis(models.Model):
PatientVisitDate = models.DateTimeField(auto_now = False, auto_now_add = True);
PatientWeight = models.PositiveIntegerField();
PatientDiagnosis = models.TextField();
patient = models.ForeignKey(Patient, on_delete = models.CASCADE);
def __str__(self):
return "Diagnosis of: " + self.patient.PatientName;
如果你看看網站:Here
您將看到一個患者列表,當點擊它時會重定向到他的頁面,我現在面臨爲每位患者添加診斷視圖的問題,我想要使用診斷字段創建表單並創建視圖爲它,然後使每個患者的診斷只出現在他的HTML頁面上。
那麼,我該怎麼做呢?
提前致謝!