Reputation: 816
Need help with setting up my django project. my settings.py :
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'DCMS_DEV',
'HOST': 'sql1165-xx-in.xxx.xxx.xxx.com,4567',
'USER': 'sakshi',
'PASSWORD': 'sakshi123',
'OPTIONS': {
'driver': "ODBC Driver 13 for SQL Server",
}
}
}
This is the error when i pass through admin:
ProgrammingError at /admin/login/
('42S02', "[42S02] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Invalid object name 'django_session'. (208) (SQLExecDirectW); [42S02] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)")
Request Method: POST
Request URL: http://localhost:8000/admin/login/?next=/admin/
Django Version: 2.1.12
Exception Type: ProgrammingError
Exception Value:
('42S02', "[42S02] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Invalid object name 'django_session'. (208) (SQLExecDirectW); [42S02] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)")
I am new bee for django. can you tell me what all basic requirement which are needed to run an django project? how do i resolve this?
Upvotes: 0
Views: 4079
Reputation: 1
I have my db ready with schema and data before I knew I need to do migrate. So I miss all these inital tables django supposed to create.
I do python manage.py migrate --fake sessions zero (to rewind the migrate for sessions model (which help create django_session when init)
python manage.py migrate --fake-init
Then I found the table in my db.
Upvotes: 0
Reputation: 117
In my case I got the same error because of simple mistake as a beginner. Instead of running python manage.py makemigrations I typed python manage.py migrate. So the table was not created then and the error meant just that it couldn't find the table where to insert the values.
Upvotes: 0
Reputation: 1
After manage.py makemigrations, I did manage.py migrate --fake appname (where appname is your application`s name) and after I did one more time manage.py migrate and it worked. Hope it will help somebody one day :)
Upvotes: 0