如何使用下面的Django模型实现模板?

时间:2017-10-17 03:19:29

标签: django django-models django-forms django-templates

我刚刚开始使用Django进行编程并制作牙科图表界面但是制作模板时遇到了麻烦。我想我的挑战始于我如何设计我以前的模型。牙科图由32颗牙齿组成,每颗牙齿都有自己的属性。以下是我的模特:

class DentalChart(models.Model):
patient = models.ForeignKey(PatientInfo, on_delete=models.CASCADE)
date = models.DateField()
dentist = models.CharField(max_length=100)
PERIODONTAL_CHOICES = (
    ('Gingivitis', 'Gingivitis'),
    ('Early Periodontitis', 'Early Periodontitis'),
    ('Moderate Periodontitis', 'Moderate Periodontitis'),
    ('Advanced Periodontitis', 'Advanced Periodontitis'),
    ('N/A', 'N/A')
)
periodontal_screening = MultiSelectField(choices=PERIODONTAL_CHOICES, default='')
OCCLUSION_CHOICES = (
    ('Class(Molar)', 'Class(Molar)'),
    ('Overjet', 'Overjet'),
    ('Overbite', 'Overbite'),
    ('Midline Deviation', 'Midline Deviation'),
    ('Crossbite', 'Crossbite'),
    ('N/A', 'N/A')
)
occlusion = MultiSelectField(choices=OCCLUSION_CHOICES, default='')
APPLIANCES_CHOICES = (
    ('Orthodontic', 'Orthodontic'),
    ('Stayplate', 'Stayplate'),
    ('Others', 'Others'),
    ('N/A', 'N/A')
)
appliances = MultiSelectField(choices=APPLIANCES_CHOICES, default='')
TMD_CHOICES = (
    ('Clenching', 'Clenching'),
    ('Clicking', 'Clicking'),
    ('Trismus', 'Trismus'),
    ('Muscle Spasm', 'Muscle Spasm'),
    ('N/A', 'N/A')
)
TMD = MultiSelectField(choices=TMD_CHOICES, default='')

class Tooth(models.Model):
chart = models.ForeignKey(DentalChart, on_delete=models.CASCADE)
tooth_id = models.CharField(max_length=2)
CONDITIONS_LIST = (
    ('', ''),
    ('Present Teeth', 'P'),
    ('Decayed', 'D'),
    ('Missing due to Carries', 'M'),
    ('Missing (Other Causes)', 'Mo'),
    ('Impacted Tooth', 'Im'),
    ('Supernumerary Tooth', 'Sp'),
    ('Root Fragment', 'Rf'),
    ('Unerupted', 'Un')
)
condition = models.CharField(max_length=30, choices=CONDITIONS_LIST, default='')
RESTORATIONS_LIST = (
    ('', ''),
    ('Amalgam Filling', 'A'),
    ('Composite Filling', 'Co'),
    ('Jacket Crown', 'Jc'),
    ('Abutment', 'Ab'),
    ('Pontic', 'Po'),
    ('Inlay', 'In'),
    ('Implant', 'Imp'),
    ('Sealants', 'S'),
    ('Removable Denture', 'Rm')
)
restoration = models.CharField(max_length=30, choices=RESTORATIONS_LIST, default='')

我使用标准HTML表单创建了此UI,以便我可以看到它的外观。但我还没有弄清楚如何合并Django,以便在创建添加和编辑牙科图表等功能后更容易引用表格。

Check image here

我很难在我的模板上显示牙科图表。我希望得到专家的一些答案和提示。谢谢!

0 个答案:

没有答案