models.py:
class Department(models.Model):
department_id = models.AutoField(primary_key=True)
department_n_key = models.CharField(max_length=30,blank=True,unique=True)
hospital_short_name = models.CharField(max_length=20)
department_name = models.CharField(max_length=50)
class EmployeesMaster(models.Model):
employee_id = models.AutoField(primary_key=True)
employee_n_key = models.CharField(max_length=30,blank=True,unique=True)
first_name = models.CharField(max_length=30)
middle_name = models.CharField(max_length=30, blank=True, null=True)
last_name = models.CharField(max_length=30, blank=True, null=True)
gender = models.CharField(max_length=12, blank=True, null=True)
class PatientMaster(models.Model):
patient_id = models.AutoField(primary_key=True)
patient_n_key = models.CharField(max_length=30,blank=True,unique=True)
first_name = models.CharField(max_length=30)
middle_name = models.CharField(max_length=30, blank=True, null=True)
last_name = models.CharField(max_length=30, blank=True, null=True)
age = models.IntegerField(blank=True, null=True)
views.py
我需要在django中应用它:
选择*从appointment_master
到patient_type
=“某物”和appointment_master
。department_n_key
进入(选择department
。department_n_key
从{{ 1}} department
。department
=“某物”)
帮助他人在Django中应用
答案 0 :(得分:0)
这不是最佳选择,但是您可以在两个查询中完成
departments_list= Department.objects.filter(departmen_name='foo').values_list('department_n_key', flat=True)
apointment_master = YourModel.objects.filter(patient_type='bar', department_n_key__in=departments_list)