【发布时间】:2020-11-13 10:39:01
【问题描述】:
当我将代码从 Django 1.9 转移到 django 2.2.9 版本时出现此错误。它在 django 1.9 中完美运行,但任何人都可以说出 2.2.9 中针对此特定搜索发生的变化。 This is the Error I'm getting, I am stuck. I tried django doc. help!
def search(request):
locations = Location.objects.all()#.order_by('location_name')
departments = Department.objects.all()#.order_by('department_name')
if not request.GET.get('location', 'none') == 'none' and not request.GET.get('specialty', 'none') == 'none':
location = request.GET.get('location',None)
specialty = request.GET.get('specialty',None)
location = Location.objects.filter(location_name=location)
hospitals = Hospital.objects.filter(location=location)
# doctors = DoctorProfile.objects.filter(user.first_name__contains=first_name)
doctors = []
for hospital in hospitals:
specialty = Department.objects.filter(department_name=specialty)
doctors = DoctorProfile.objects.filter(hospital=hospital, specialization=specialty)
return render(request, 'infrastructure/search.html', {'doctors': doctors, 'locations': locations, 'departments': departments})
return render(request, 'infrastructure/search.html', {'locations': locations, 'departments': departments})
【问题讨论】:
标签: python python-3.x django django-models django-views