Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: MySQL no such table: aidata.django_session

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")
like image 800
gabberr Avatar asked May 09 '12 12:05

gabberr


Video Answer


1 Answers

  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

like image 60
Francis Yaconiello Avatar answered Oct 04 '22 13:10

Francis Yaconiello