I ran into a problem while running my project, I encountered this error
Cannot resolve keyword 'PatientInfoID' into field. Choices are: Content, Dept, Doc, Doc_InfoID, Doc_InfoID_id, Patient_InfoID, Patient_InfoID_id, email, id, name, patienthistory, ref, status
While this is my views.py
def profile(request):
user = request.user
patient = Patient.objects.filter(user = user)
appointment = Appointment.objects.filter(PatientInfoID = patient)
patienthis = PatientHistory.objects.filter(Appnt_InfoID=appointment)
return render(request, 'appointment.html', {'histories' : patienthis})
this is my urls.py
path('profile', views.profile, name='profile')
and this is my models.py
class Appointment(models.Model):
Patient_InfoID = models.ForeignKey(Patient, on_delete=models.CASCADE, null=True)
Doc_InfoID = models.ForeignKey(Doctor, on_delete=models.CASCADE, null=True)
name = models.CharField(max_length=100)
email = models.CharField(max_length=100)
phone = models.IntegerField
Adate = models.DateField
Dept = models.CharField(max_length=100)
Doc = models.CharField(max_length=100)
Content = models.CharField(max_length=500)
status = models.CharField(max_length=10, choices=COLOR_CHOICES, default='new')
ref = models.CharField(max_length=100)
CodePudding user response:
Shouldn't you be using Patient_InfoID
instead of PatientInfoID
in your views.py?