gpt4 book ai didi

Django::OperationalError at/admin/login/无法打开数据库文件

转载 作者:行者123 更新时间:2023-12-05 00:23:08 25 4
gpt4 key购买 nike

我知道已经有 同样的问题 ,我也尝试了给定的解决方案,但它努力工作 对我来说,因此我正在写我自己的问题。
大家好,我正在使用 apache2 服务器部署 django 服务器,当我尝试我的主机 IP 地址时,它工作正常,因为它显示 成功了 页面,适用于 IPADRESS/管理员 也但是在填写凭据并按回车后会产生这个错误

***OperationalError at /admin/login/
unable to open database file***

我的错误看起来像
Environment:


Request Method: POST
Request URL: http://192.168.1.105/admin/login/?next=/admin/

Django Version: 1.7.4
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'managementdashboard')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/admin/sites.py" in login
361. return login(request, **defaults)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
76. return view(request, *args, **kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/auth/views.py" in login
44. auth_login(request, form.get_user())
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in login
96. request.session.cycle_key()
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in cycle_key
279. self.create()
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in create
41. self.save(must_create=True)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in save
64. obj.save(force_insert=must_create, using=using)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/base.py" in save
589. force_update=force_update, update_fields=update_fields)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/base.py" in save_base
617. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/base.py" in _save_table
698. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/base.py" in _do_insert
731. using=using, raw=raw)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
92. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/query.py" in _insert
921. return query.get_compiler(using=using).execute_sql(return_id)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
920. cursor.execute(sql, params)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
81. return super(CursorDebugWrapper, self).execute(sql, params)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/utils.py" in __exit__
94. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
485. return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /admin/login/
Exception Value: unable to open database file

需要儿子尽可能的帮助,提前谢谢你。

最佳答案

您的 Apache 用户没有写入数据库所需的权限。

修改您的 settings.py以便它显示数据库的绝对路径,例如:

DATABASE_NAME = '/var/www/dashboardapp/whatever/path/db.sqlite3'

然后在 Linux 提示符下键入以下命令以设置正确的权限:
chown www-data /var/www/dashboardapp/whatever/path/
chown www-data /var/www/dashboardapp/whatever/path/db.sqlite3

关于Django::OperationalError at/admin/login/无法打开数据库文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28716741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com