I am trying to generate a query for which I get the expected result in django shell, but for the same query, I am getting an error that the attribute for the model does not exist.
First the shell:
>>> from dbaccess.models import *
>>> applicantObject = Applicant.objects.get(pk=5)
>>> vol = VolInterview.objects.get(applicant=applicantObject)
>>> vol
<VolInterview: Rajon>
From views.py
from models import *
def addIntCandidate(request):
applicants = Applicant.objects.filter(applicationStatus="Pending")
interviews = Interview.objects.all()
message = []
if request.method == 'POST':
applicant = request.POST.get('applicant')
...
# the value of applicant at this point is 5
applicantObject = Applicant.objects.get(pk=applicant)
prevRejected = VolInterview.objects.get(applicant=applicantObject)
...
Error message:
type object 'VolInterview' has no attribute 'objects'
Traceback:
E:\projects_directory\djangoprojects\kpr-admin-db\dbaccess\views.py in addIntCandidate
prevRejected = VolInterview.objects.get(applicant=applicantObject)
What am I doing wrong?