Django可疑操作请求会话已删除

时间:2017-06-30 08:49:05

标签: django python-3.x django-wsgi

我尝试在我的服务器上运行我的django页面,并在浏览器中发现以下错误消息:

  

/ lfp / filter /

处的SuspiciousOperation      

在请求完成之前删除了请求的会话。该   例如,用户可能已在并发请求中注销。

你可以在这里找到追溯:

Environment:


Request Method: GET
Request URL: http://localhost/pass/lfp/filter/

Django Version: 1.11.2
Python Version: 3.6.1
Installed Applications:
['django_tables2',
 'pass_list.apps.PassListConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/lib/python3.6/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)

File "/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py" in execute
  328.         return Database.Cursor.execute(self, query, params)

The above exception (attempt to write a readonly database) was the direct cause of the following exception:

File "/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py" in save
  87.                 obj.save(force_insert=must_create, force_update=not must_create, using=using)

File "/lib/python3.6/site-packages/django/db/models/base.py" in save
  806.                        force_update=force_update, update_fields=update_fields)

File "/lib/python3.6/site-packages/django/db/models/base.py" in save_base
  836.             updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)

File "/lib/python3.6/site-packages/django/db/models/base.py" in _save_table
  903.                                       forced_update)

File "/lib/python3.6/site-packages/django/db/models/base.py" in _do_update
  953.         return filtered._update(values) > 0

File "/lib/python3.6/site-packages/django/db/models/query.py" in _update
  664.         return query.get_compiler(self.db).execute_sql(CURSOR)

File "/lib/python3.6/site-packages/django/db/models/sql/compiler.py" in execute_sql
  1191.         cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)

File "/lib/python3.6/site-packages/django/db/models/sql/compiler.py" in execute_sql
  886.             raise original_exception

File "/lib/python3.6/site-packages/django/db/models/sql/compiler.py" in execute_sql
  876.             cursor.execute(sql, params)

File "/lib/python3.6/site-packages/django/db/backends/utils.py" in execute
  80.             return super(CursorDebugWrapper, self).execute(sql, params)

File "/lib/python3.6/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)

File "/lib/python3.6/site-packages/django/db/utils.py" in __exit__
  94.                 six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/lib/python3.6/site-packages/django/utils/six.py" in reraise
  685.             raise value.with_traceback(tb)

File "/lib/python3.6/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)

File "/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py" in execute
  328.         return Database.Cursor.execute(self, query, params)

During handling of the above exception (attempt to write a readonly database), another exception occurred:

File "/lib/python3.6/site-packages/django/contrib/sessions/middleware.py" in process_response
  58.                             request.session.save()

File "/lib/python3.6/site-packages/django/contrib/sessions/backends/db.py" in save
  94.                 raise UpdateError

During handling of the above exception (), another exception occurred:

File "/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/lib/python3.6/site-packages/django/utils/deprecation.py" in __call__
  142.             response = self.process_response(request, response)

File "/lib/python3.6/site-packages/django/contrib/sessions/middleware.py" in process_response
  61.                                 "The request's session was deleted before the "

Exception Type: SuspiciousOperation at /lfp/filter/
Exception Value: The request's session was deleted before the request completed. The user may have logged out in a concurrent request, for example.

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

我解决了我的问题。这是访问管理的一个问题。 db.sqlite3文件只是可读的。改变权利解决了我的问题。