Django:没有这样的表:django_session [英] Django: no such table: django_session

查看:1265
本文介绍了Django:没有这样的表:django_session的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经找到了这个标题的几个主题,但他们的解决方案都没有为我工作。我在我的服务器上运行两个Django站点,通过Apache在我的Nginx前端(用于静态文件)的两个端口上使用不同的虚拟主机。一个站点使用MySql并运行正常。另一个使用Sqlite3并得到标题中的错误。

I have found several topics with this title, but none of their solutions worked for me. I have two Django sites running on my server, both through Apache using different virtualhosts on two ports fed by my Nginx frontend (using for static files). One site uses MySql and runs just fine. The other uses Sqlite3 and gets the error in the title.

我下载了一个sqlite.exe的副本,并查看了mysite.sqlite3(此目录中的SQLite数据库)文件并且确实有一个django_session表,其中包含有效数据。我的系统32中有sqlite.exe以及Python路径中的site-packages文件夹。

I downloaded a copy of sqlite.exe and looked at the mysite.sqlite3 (SQLite database in this directory) file and there is indeed a django_session table with valid data in it. I have the sqlite.exe in my system32 as well as the site-packages folder in my Python path.

这是我的settings.py文件的一部分: p>

Here is a section of my settings.py file:

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'mysite.sqlite3',         # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

我没有使用python manage.py syncdb错误,只是一个没有Fixtures评论。

I did use the python manage.py syncdb with no errors and just a "No Fixtures" comment.

有没有人有什么想法可能会发生在这里?我正在考虑将所有东西都转移到我的旧朋友MySql,只是忽略Sqlite,因为它总是给我一些麻烦。我只是使用它,为了知道它的利益。我没有压倒性的原因我应该用它。但再次,只是为了我的教诲,有谁知道这个问题是什么?我不喜欢放弃。

Does anyone have any ideas what else might be going on here? I'm considering just transferring everything over to my old pal MySql and just ignoring Sqlite, as really it's always given me some kind of trouble. I was only using it for the benefit of knowing it anyway. I have no overwhelming reason why I should use it. But again, just for my edification does anyone know what this problem is? I don't like to give up.

推荐答案

可能是服务器使用与<$ c不同的工作目录$ c> manage.py 命令。由于您提供了sqlite数据库的相对路径,所以在工作目录中创建。尝试使用绝对路径,例如:

It could be that the server uses a different working directory than the manage.py command. Since you provide a relative path to the sqlite database, it is created in the working directory. Try it with an absolute path, e.g.:

'NAME': '/tmp/mysite.sqlite3',

请记住,您必须运行 ./ manage.py syncdb 再次将您现有的数据库与现有表复制到 / tmp

Remember that you have to either run ./manage.py syncdb again or copy your current database with the existing tables to /tmp.

如果它解决了错误消息,你可以找到比 / tmp 更好的地方: - )

If it resolves the error message, you can look for a better place than /tmp :-)

这篇关于Django:没有这样的表:django_session的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆