Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 员工用户不';在没有明确分配管理站点的情况下,他们没有访问管理站点的权限_Python_Django_Windows_Permission Denied - Fatal编程技术网

Python 员工用户不';在没有明确分配管理站点的情况下,他们没有访问管理站点的权限

Python 员工用户不';在没有明确分配管理站点的情况下,他们没有访问管理站点的权限,python,django,windows,permission-denied,Python,Django,Windows,Permission Denied,我正在使用Django 3.1.2,超级用户在管理站点中添加的职员用户在登录后无法访问同一管理站点。/admin/return 403禁止的错误中的所有页面 我正在虚拟环境(venv)中使用Windows10、Python3.8.5。我的命令是在Git Bash中发出的。它首先发生在另一个项目中,所以我创建了一个新项目来尝试。Firefox、Edge和Chrome中也存在同样的错误 正是我所做的: Git Bash: $ mkdir test_staff $ cd test_staff/ $ p

我正在使用Django 3.1.2,超级用户在管理站点中添加的职员用户在登录后无法访问同一管理站点。/admin/return 403禁止的错误中的所有页面

我正在虚拟环境(venv)中使用Windows10、Python3.8.5。我的命令是在Git Bash中发出的。它首先发生在另一个项目中,所以我创建了一个新项目来尝试。Firefox、Edge和Chrome中也存在同样的错误

正是我所做的:

Git Bash:

$ mkdir test_staff
$ cd test_staff/
$ python -m venv venv_dev
$ source venv_dev/Scripts/activate
$ pip install Django==3.1.2
$ pip list
    Package    Version
    ---------- -------
    asgiref    3.2.10
    Django     3.1.2
    pip        20.1.1
    pytz       2020.1
    setuptools 47.1.0
    sqlparse   0.4.1
$ django-admin startproject mysite
$ cd mysite/
$ python manage.py migrate
$ winpty python manage.py createsuperuser
    username: admin
    password: 12345
$ python manage.py runserver
Login with "admin" user: ​http://localhost:8000/admin/login
Add staff user: ​http://localhost:8000/admin/auth/user/add/
    username: staff_user
    password: Ax47y](U[1fpw;8H2?})
    > Save and continue editing
    staff status = True
    > Save 
Logout: ​http://localhost:8000/admin/logout/
Login with "staff_user": ​http://localhost:8000/admin/login
[09/Oct/2020 12:49:39] "GET /admin/ HTTP/1.1" 200 2282
Forbidden (Permission denied): /admin/auth/user/
Traceback (most recent call last):
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\options.py", line 614, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\sites.py", line 233, in inner
    return view(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\options.py", line 1690, in changelist_view
    raise PermissionDenied
django.core.exceptions.PermissionDenied
[09/Oct/2020 12:53:50] "GET /admin/auth/user/ HTTP/1.1" 403 135
浏览器:

$ mkdir test_staff
$ cd test_staff/
$ python -m venv venv_dev
$ source venv_dev/Scripts/activate
$ pip install Django==3.1.2
$ pip list
    Package    Version
    ---------- -------
    asgiref    3.2.10
    Django     3.1.2
    pip        20.1.1
    pytz       2020.1
    setuptools 47.1.0
    sqlparse   0.4.1
$ django-admin startproject mysite
$ cd mysite/
$ python manage.py migrate
$ winpty python manage.py createsuperuser
    username: admin
    password: 12345
$ python manage.py runserver
Login with "admin" user: ​http://localhost:8000/admin/login
Add staff user: ​http://localhost:8000/admin/auth/user/add/
    username: staff_user
    password: Ax47y](U[1fpw;8H2?})
    > Save and continue editing
    staff status = True
    > Save 
Logout: ​http://localhost:8000/admin/logout/
Login with "staff_user": ​http://localhost:8000/admin/login
[09/Oct/2020 12:49:39] "GET /admin/ HTTP/1.1" 200 2282
Forbidden (Permission denied): /admin/auth/user/
Traceback (most recent call last):
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\options.py", line 614, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\sites.py", line 233, in inner
    return view(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\options.py", line 1690, in changelist_view
    raise PermissionDenied
django.core.exceptions.PermissionDenied
[09/Oct/2020 12:53:50] "GET /admin/auth/user/ HTTP/1.1" 403 135
结果:

Git Bash:

$ mkdir test_staff
$ cd test_staff/
$ python -m venv venv_dev
$ source venv_dev/Scripts/activate
$ pip install Django==3.1.2
$ pip list
    Package    Version
    ---------- -------
    asgiref    3.2.10
    Django     3.1.2
    pip        20.1.1
    pytz       2020.1
    setuptools 47.1.0
    sqlparse   0.4.1
$ django-admin startproject mysite
$ cd mysite/
$ python manage.py migrate
$ winpty python manage.py createsuperuser
    username: admin
    password: 12345
$ python manage.py runserver
Login with "admin" user: ​http://localhost:8000/admin/login
Add staff user: ​http://localhost:8000/admin/auth/user/add/
    username: staff_user
    password: Ax47y](U[1fpw;8H2?})
    > Save and continue editing
    staff status = True
    > Save 
Logout: ​http://localhost:8000/admin/logout/
Login with "staff_user": ​http://localhost:8000/admin/login
[09/Oct/2020 12:49:39] "GET /admin/ HTTP/1.1" 200 2282
Forbidden (Permission denied): /admin/auth/user/
Traceback (most recent call last):
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\options.py", line 614, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\sites.py", line 233, in inner
    return view(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\options.py", line 1690, in changelist_view
    raise PermissionDenied
django.core.exceptions.PermissionDenied
[09/Oct/2020 12:53:50] "GET /admin/auth/user/ HTTP/1.1" 403 135
其他URL:

Git Bash:

$ mkdir test_staff
$ cd test_staff/
$ python -m venv venv_dev
$ source venv_dev/Scripts/activate
$ pip install Django==3.1.2
$ pip list
    Package    Version
    ---------- -------
    asgiref    3.2.10
    Django     3.1.2
    pip        20.1.1
    pytz       2020.1
    setuptools 47.1.0
    sqlparse   0.4.1
$ django-admin startproject mysite
$ cd mysite/
$ python manage.py migrate
$ winpty python manage.py createsuperuser
    username: admin
    password: 12345
$ python manage.py runserver
Login with "admin" user: ​http://localhost:8000/admin/login
Add staff user: ​http://localhost:8000/admin/auth/user/add/
    username: staff_user
    password: Ax47y](U[1fpw;8H2?})
    > Save and continue editing
    staff status = True
    > Save 
Logout: ​http://localhost:8000/admin/logout/
Login with "staff_user": ​http://localhost:8000/admin/login
[09/Oct/2020 12:49:39] "GET /admin/ HTTP/1.1" 200 2282
Forbidden (Permission denied): /admin/auth/user/
Traceback (most recent call last):
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\options.py", line 614, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\sites.py", line 233, in inner
    return view(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
File "C:\Users\DELL\Documents\github\test_staff\venv_dev\lib\site-packages\django\contrib\admin\options.py", line 1690, in changelist_view
    raise PermissionDenied
django.core.exceptions.PermissionDenied
[09/Oct/2020 12:53:50] "GET /admin/auth/user/ HTTP/1.1" 403 135

员工用户只有在我明确向用户分配身份验证权限的情况下才能访问管理站点。

应该是这样的。您的新员工用户没有任何添加或编辑任何内容的权限。尝试创建具有一组权限的新组(例如添加/编辑用户或其他模型),然后将您的员工用户添加到该组