Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django project using wrong (old) database settings

recently I started a small Django project that I developed on a local machine using a SQLite3 database and the integrated development server. I now copied the whole project to a server running Debian.

Everything worked well as long as I kept using the SQLite3 database. Now I wanted to switch to a local MySQL database, so I changed the settings.py file in my project's root folder, created the database and added a user. I then ran syncdb and it created the needed tables without any problems.

Now I wanted to use the app, but I keep getting errors, because Django can not find the tables - neither the 'standard tables' like django_sessions nor my own tables - even though they are there (I checked the database).

The one thing that seems awkward about the DatabaseError pages I get is the following line:

Exception Location: /usr/local/lib/python2.6/dist-packages/django/db/backends/sqlite3/base.py in execute, line 234

It seems like Django is still using the SQLite3 backend even though I set it to use the MySQL backend.

The other thing that nearly makes me freak out is this: I deleted the data.sqlite file in my app's root folder using rm. But when I use my app, the file is being recreated!

Can anyone tell me where I went wrong?

like image 333
user1136324 Avatar asked Jan 07 '12 19:01

user1136324


2 Answers

When running in production with mod_wsgi or mod_python, new code isn't incorporated until you reload/restart the webserver.

If you are using apache with mod_wsgi, you can also touch the wsgi.py file to restart the python code only.

like image 197
boatcoder Avatar answered Nov 05 '22 10:11

boatcoder


If running on apache run "sudo /etc/init.d/apache2 reload" everytime you make a change.

like image 24
shaytac Avatar answered Nov 05 '22 12:11

shaytac