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

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

问题描述

我在Pycharm的Windows 7上运行Django 1.4,并且安装了WAMP,因为我需要在MySQL表中拥有我的数据。



这是从设置。 py

  DATABASES = {
'default':{
'ENGINE':'django.db。 backend.mysql',
'NAME':'aidata',
'USER':'root'
}
}
/ pre>

从installed_apps我取消注释:

 'django.contrib sessions'

运行 manage.py syncdb 不会在我的mysqldb中创建任何表(甚至模型)。



尝试访问时,我收到错误 / admin /

  DatabaseError at / admin / 
(1146,Tableaidata。 django_session'不存在)


解决方案


  1. 双重检查数据库凭据

  2. 确保您在您的mi中取消注释此行ddleware:



    MIDDLEWARE_CLASSES =(
    ....
    'django.contrib.sessions.middleware.SessionMiddleware',


  3. 然后尝试 python manage.py syncdb


  4. 如果您仍然有问题发布任何输出



编辑 - 下一个检查:




  1. 你有一个django_content_type表吗?

  2. 如果是,那个表是否有一个会话记录? >
  3. 如果是这样,删除会话记录并尝试 python manage.py syncdb



编辑 - 步骤3:



现在我猜,发布您的设置文件,以便我可以进行有意义的故障排除尝试




  1. 如果您有一个运行

  2. 进入文件浏览器并删除settings.pyc,请停止您的服务器文件

  3. 尝试 python manage.py syncdb

我的想法是一个pyc文件与sqlLite我nfo可能被缓存而不是重新生成



编辑 - 步骤4:



您的settings.py中的所有内容对我好吗为我尝试一些东西创建一个新的django项目,不要启用管理员或添加在你的应用程序,我只想知道从头开始你的django安装中的所有内容似乎正在工作


  1. django-admin.py startproject testsite

  2. 执行数据库配置/设置

  3. 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")

解决方案

  1. Double check the db credentials
  2. make sure you uncommented this line in your middleware:

    MIDDLEWARE_CLASSES = ( .... 'django.contrib.sessions.middleware.SessionMiddleware', )

  3. then try to python manage.py syncdb.

  4. if you are still having issues post any output

EDIT -- NEXT CHECK:

  1. do you have a "django_content_type" table?
  2. if so, does that table have a "session" record?
  3. 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

  1. Stop your server if you have one running
  2. go into your file browser and delete the settings.pyc file
  3. 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

  1. django-admin.py startproject testsite
  2. do the database configuration/setup
  3. python manage.py syncdb

let me know if the models create properly

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

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