Django:MySQL没有这样的表:aidata.django_session [英] Django: MySQL no such table: aidata.django_session
问题描述
这是从设置。 py
DATABASES = {
/ pre>
'default':{
'ENGINE':'django.db。 backend.mysql',
'NAME':'aidata',
'USER':'root'
}
}
从installed_apps我取消注释:
'django.contrib sessions'
运行
manage.py syncdb
不会在我的mysqldb中创建任何表(甚至模型)。
尝试访问时,我收到错误
/ admin /
DatabaseError at / admin /
(1146,Tableaidata。 django_session'不存在)
解决方案
- 双重检查数据库凭据
确保您在您的mi中取消注释此行ddleware:
MIDDLEWARE_CLASSES =(
....
'django.contrib.sessions.middleware.SessionMiddleware',
)
然后尝试
python manage.py syncdb
。
- 如果您仍然有问题发布任何输出
编辑 - 下一个检查:
- 你有一个django_content_type表吗?
- 如果是,那个表是否有一个会话记录? >
- 如果是这样,删除会话记录并尝试
python manage.py syncdb
编辑 - 步骤3:
现在我猜,发布您的设置文件,以便我可以进行有意义的故障排除尝试
- 如果您有一个运行
- 进入文件浏览器并删除settings.pyc,请停止您的服务器文件
- 尝试
python manage.py syncdb
我的想法是一个pyc文件与sqlLite我nfo可能被缓存而不是重新生成
编辑 - 步骤4:
您的settings.py中的所有内容对我好吗为我尝试一些东西创建一个新的django项目,不要启用管理员或添加在你的应用程序,我只想知道从头开始你的django安装中的所有内容似乎正在工作
- django-admin.py startproject testsite
- 执行数据库配置/设置
- python manage.py syncdb
让我知道模型是否正常创建
I'm running Django 1.4 on Windows 7 in Pycharm and I installed WAMP because I need to have my data in a MySQL table.
This is from setting.py
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'aidata', 'USER': 'root' } }
From installed_apps I uncommented:
'django.contrib.sessions'
Running
manage.py syncdb
does not create any tables ( even models) in my mysqldb.I get the error when trying to acces
/admin/
DatabaseError at /admin/ (1146, "Table 'aidata.django_session' doesn't exist")
解决方案
- Double check the db credentials
make sure you uncommented this line in your middleware:
MIDDLEWARE_CLASSES = ( .... 'django.contrib.sessions.middleware.SessionMiddleware', )
then try to
python manage.py syncdb
.- if you are still having issues post any output
EDIT -- NEXT CHECK:
- do you have a "django_content_type" table?
- if so, does that table have a "session" record?
- if so, delete the session record and try to
python manage.py syncdb
EDIT -- STEP 3:
now i'm guessing, post up your settings file so i can make meaningful troubleshooting attempts
- Stop your server if you have one running
- go into your file browser and delete the settings.pyc file
- try to
python manage.py syncdb
my thought is that a pyc file with the sqlLite info may be cached and not regenerating
EDIT -- STEP 4:
everything in your settings.py look ok to me. try something for me? create a new django project, don't enable the admin or add in your apps i just want to know if from scratch everything in your django install seems to be working
- django-admin.py startproject testsite
- do the database configuration/setup
- python manage.py syncdb
let me know if the models create properly
这篇关于Django:MySQL没有这样的表:aidata.django_session的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!