这是我的错误 / Slife /
处的FieldError无法将关键字“激活”解析为字段。选项包括:活动,评论,创建,详细信息,功能,id,图像,已修改,名称,选项,子弹,视图
请求方法:GET 要求网址:http://localhost:8000/Slife/ Django版本:2.2.1 异常类型:FieldError 异常值:
无法将关键字“激活”解析为字段。选项包括:活动,评论,创建,详细信息,功能,id,图像,已修改,名称,选项,子弹,视图
异常位置:names_to_path,第1420行中的C:\ Users \ essum \ Envs \ Py1 \ lib \ site-packages \ django \ db \ models \ sql \ query.py Python可执行文件:C:\ Users \ essum \ Envs \ Py1 \ Scripts \ python.exe 的Python版本:3.7.3 Python路径:
['C:\ Users \ essum \ Envs \ LIFE', 'C:\ Users \ essum \ Envs \ Py1 \ Scripts \ python37.zip', 'C:\ Users \ essum \ Envs \ Py1 \ DLLs', 'C:\ Users \ essum \ Envs \ Py1 \ lib', 'C:\ Users \ essum \ Envs \ Py1 \ Scripts', 'c:\ users \ essum \ appdata \ local \ programs \ python \ python37 \ Lib', 'c:\ users \ essum \ appdata \ local \ programs \ python \ python37 \ DLLs', 'C:\ Users \ essum \ Envs \ Py1', 'C:\ Users \ essum \ Envs \ Py1 \ lib \ site-packages']
服务器时间:2019年6月10日星期一09:56:18 +0000 追溯切换到复制和粘贴视图
C:\Users\essum\Envs\Py1\lib\site-packages\django\core\handlers\exception.py in inner
response = get_response(request)
…
▶ Local vars
C:\Users\essum\Envs\Py1\lib\site-packages\django\core\handlers\base.py in _get_response
response = self.process_exception_by_middleware(e, request)
…
▶ Local vars
C:\Users\essum\Envs\Py1\lib\site-packages\django\core\handlers\base.py in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
…
▶ Local vars
C:\Users\essum\Envs\LIFE\Slife\views.py in home
categories = Category.objects.filter(activate=True,views__gte=3000).order_by('-views')
…
▶ Local vars
C:\Users\essum\Envs\Py1\lib\site-packages\django\db\models\manager.py in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
…
▶ Local vars
C:\Users\essum\Envs\Py1\lib\site-packages\django\db\models\query.py in filter
return self._filter_or_exclude(False, *args, **kwargs)
…
▶ Local vars
C:\Users\essum\Envs\Py1\lib\site-packages\django\db\models\query.py in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
…
▶ Local vars
C:\Users\essum\Envs\Py1\lib\site-packages\django\db\models\sql\query.py in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
…
▶ Local vars
C:\Users\essum\Envs\Py1\lib\site-packages\django\db\models\sql\query.py in _add_q
split_subq=split_subq, simple_col=simple_col,
…
▶ Local vars
C:\Users\essum\Envs\Py1\lib\site-packages\django\db\models\sql\query.py in build_filter
lookups, parts, reffed_expression = self.solve_lookup_type(arg)
…
▶ Local vars
C:\Users\essum\Envs\Py1\lib\site-packages\django\db\models\sql\query.py in solve_lookup_type
_, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
…
▶ Local vars
C:\Users\essum\Envs\Py1\lib\site-packages\django\db\models\sql\query.py in names_to_path
"Choices are: %s" % (name, ", ".join(available)))
…
▶ Local vars
答案 0 :(得分:1)
此行告诉您什么地方错了
Cannot resolve keyword 'activate' into field. Choices are: active, comment, created, details, featured, id, image, modified, name, option, slug, views
您需要将错误行更改为
categories = Category.objects.filter(active=True,views__gte=3000).order_by('-views')
您的模型有一个名为“活动”的字段,但是您尝试过滤不存在的“激活”字段。