我正在尝试生成一个查询,我在 django shell 中获得了预期的结果,但是对于相同的查询,我收到一个错误,即模型的属性不存在。
首先是外壳:
>>> from dbaccess.models import *
>>> applicantObject = Applicant.objects.get(pk=5)
>>> vol = VolInterview.objects.get(applicant=applicantObject)
>>> vol
<VolInterview: Rajon>
来自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)
...
错误信息:
type object 'VolInterview' has no attribute 'objects'
追溯:
E:\projects_directory\djangoprojects\kpr-admin-db\dbaccess\views.py in addIntCandidate
prevRejected = VolInterview.objects.get(applicant=applicantObject)
我究竟做错了什么?