Cannot apply DjangoModelPermissionsOrAnonReadOnly on a view that does not set `.queryset` or have a `.get_queryset()` method.
Request Method: | GET |
---|---|
Request URL: | http://127.0.0.1:8000/course/fbv/list/ |
Django Version: | 3.1.7 |
Exception Type: | AssertionError |
Exception Value: | Cannot apply DjangoModelPermissionsOrAnonReadOnly on a view that does not set `.queryset` or have a `.get_queryset()` method. |
Exception Location: | F:\PythonEnvironment\py3_environ\lib\site-packages\rest_framework\permissions.py, line 209, in _queryset |
Python Executable: | F:\PythonEnvironment\py3_environ\Scripts\python.exe |
Python Version: | 3.6.4 |
Python Path: | ['F:\\Py_Project\\dj_drf', 'F:\\Py_Project\\dj_drf', 'E:\\pycharm\\PyCharm 2019.3.3\\plugins\\python\\helpers\\pycharm_display', 'F:\\PythonEnvironment\\py3_environ\\Scripts\\python36.zip', 'C:\\python3\\DLLs', 'C:\\python3\\lib', 'C:\\python3', 'F:\\PythonEnvironment\\py3_environ', 'F:\\PythonEnvironment\\py3_environ\\lib\\site-packages', 'F:\\PythonEnvironment\\py3_environ\\lib\\site-packages\\setuptools-40.8.0-py3.6.egg', 'F:\\PythonEnvironment\\py3_environ\\lib\\site-packages\\pip-19.0.3-py3.6.egg', 'E:\\pycharm\\PyCharm ' '2019.3.3\\plugins\\python\\helpers\\pycharm_matplotlib_backend'] |
Server time: | Sun, 11 Apr 2021 23:08:36 +0800 |
queryset = X.objects.get(id=1)
因为你用了全局的权限认证,所以要直到认证谁,要把用户对象给到权限认证模块