I want to switch db backends from django_pyodbc to sqlite in order to make sure my custom user model works before I start messing around with my db. So I commented out the DATABASES setting and put in a new one which uses sqlite. I've done this before (on this project as well) with no problems, but now I have no idea what's going on.
syncdb
responds as if it is looking at a db that has already been synced, i.e. it does nothing.
In shell
, settings.DATABASES returns the settings for my original db (shockingly, it still thinks I'm using the sqlserver_ado backend which I switched out for django_pyodbc a couple of weeks ago), and I can access models which don't have any relation to my user model, but those that do return an error (because I changed some user field names). In the traceback I see that it is still looking at the MSSQL db.
runserver
works, but when I go to a page I get a DatabaseError - no such table: django_session. The exception location is in ...\django\db\backends\sqlite3\...
Here is the full traceback:
Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
187. response = middleware_method(request, response)
File "C:\Python27\lib\site-packages\django\contrib\sessions\middleware.py" in process_response
28. if request.session.get_expire_at_browser_close():
File "C:\Python27\lib\site-packages\django\contrib\sessions\backends\base.py" in get_expire_at_browser_close
253. if self.get('_session_expiry') is None:
File "C:\Python27\lib\site-packages\django\contrib\sessions\backends\base.py" in get
57. return self._session.get(key, default)
File "C:\Python27\lib\site-packages\django\contrib\sessions\backends\base.py" in _get_session
168. self._session_cache = self.load()
File "C:\Python27\lib\site-packages\django\contrib\sessions\backends\db.py" in load
18. expire_date__gt=timezone.now()
File "C:\Python27\lib\site-packages\django\db\models\manager.py" in get
143. return self.get_query_set().get(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in get
398. num = len(clone)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in __len__
106. self._result_cache = list(self.iterator())
File "C:\Python27\lib\site-packages\django\db\models\query.py" in iterator
317. for row in compiler.results_iter():
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py" in results_iter
775. for rows in self.execute_sql(MULTI):
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
840. cursor.execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\backends\util.py" in execute
41. return self.cursor.execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\backends\sqlite3\base.py" in execute
366. six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
File "C:\Python27\lib\site-packages\django\db\backends\sqlite3\base.py" in execute
362. return Database.Cursor.execute(self, query, params)
And yes; I have tried turning my computer on and off again. Any ideas? Thank you.
== EDIT ==
Here are my DATABASES settings:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': PROJECT_ROOT.child('temp_db').child('sqlite.db'),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.django_pyodbc',
# 'NAME': my_project,
# 'USER': '',
# 'PASSWORD': '',
# 'HOST': my_host,
# 'PORT': '',
# 'OPTIONS': {
# 'driver': 'SQL Server',
# 'MARS_Connection': True,
# }
# }
# }
== EDIT2 ==
I looked in my settings folder to find __init__.py
, base.py
, dev.py
and their associated .pyc files. In addition, there is a settings.pyc
file with no corresponding .py file (I'm assuming this is a remnant from before I chopped up settings.py
into seperate pieces. I tried deleting it and doing syncdb
again and got this:
C:\...\my_project>manage.py syncdb --settings=my_project.settings.devettings=web_ems.
Traceback (most recent call last):
File "C:\...\my_project\manage.py", line 15, in <module>
if settings.DEBUG:
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 53, in __getattr__
self._setup(name)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 48, in _setup
self._wrapped = Settings(settings_module)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 134, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s"% (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'my_project.settings.settings' (Is it on sys
.path?): No module named settings