这是查询:
comment = AdditionalComment.objects.get(form = form, student = students[student])
在我的本地机器上完美运行。
我已将项目部署到DO VPS,每当我尝试访问视图时,即使我可以在管理面板中看到AdditionalComment,我也会收到此错误:
File "/home/smartsurvey/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/smartsurvey/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/smartsurvey/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/smartsurvey/venv/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/smartsurvey/smart-survey/forms/views.py", line 195, in view_replies
comment = AdditionalComment.objects.get(form = form, student = students[student])
File "/home/smartsurvey/venv/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/smartsurvey/venv/lib/python3.6/site-packages/django/db/models/query.py", line 380, in get
self.model._meta.object_name
forms.models.DoesNotExist: AdditionalComment matching query does not exist.`
知道它可能是什么?如果您需要更多信息,请告诉我
答案 0 :(得分:0)
我意识到我在查询用户评论之前是在查询数据库,所以我添加了一个if语句来检查他们是否已经回复了。
答案 1 :(得分:-1)
错误说:没有附加评论这样的参数。您需要创建AdditionalComment实例,然后才能获得它。