I have a model object in django like so...
from django.db import models
class Person(models.Model):
employee_title = models.CharField(max_length=150)
pk_person_id = models.IntegerField(primary_key=True)
department_name = models.CharField(max_length=240)
cost_center = models.CharField(max_length=150)
user_name = models.CharField(max_length=100)
def __str__(self):
return self.user_name
class Meta:
managed = False
db_table = 'company_hr_idm_data_v'
and in my view I am doing a simple get on the Person object like so...
testobj = Person.objects.using('oracle').get(pk=4)
The code errors out with a DatabaseError
that says
ORA-01861: literal does not match format string
Here is the stack trace I code when I have my debug mode set to true in my settings.py
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/roles/testing
Django Version: 1.7.2
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'roles')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/adjeibad/.virtualenvs/wwtmlserver/entitlements/roles/views/Organization.py" in test
9. testobj = Person.objects.using('oracle').get(pk=4)
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site- packages/django/db/models/query.py" in get
351. num = len(clone)
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site-packages/django/db/models/query.py" in __len__
122. self._fetch_all()
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
966. self._result_cache = list(self.iterator())
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site-packages/django/db/models/query.py" in iterator
265. for row in compiler.results_iter():
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
700. for rows in self.execute_sql(MULTI):
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
786. cursor.execute(sql, params)
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
81. return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site-packages/django/db/utils.py" in __exit__
94. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)
File "/Users/adjeibad/.virtualenvs/wwtmlserver/lib/python2.7/site- packages/django/db/backends/oracle/base.py" in execute
916. return self.cursor.execute(query, self._param_generator(params))
Exception Type: DatabaseError at /roles/testing
Exception Value: ORA-01861: literal does not match format string
Oh! also here is the query that is generated...
SELECT * FROM (SELECT ROWNUM AS "_RN", "_SUB".* FROM (SELECT "COMPANY_HR_IDM_DATA_V"."EMPLOYEE_TITLE", "COMPANY_HR_IDM_DATA_V"."PK_PERSON_ID", "COMPANY_HR_IDM_DATA_V"."DEPARTMENT_NAME", "COMPANY_HR_IDM_DATA_V"."COST_CENTER", "COMPANY_HR_IDM_DATA_V"."USER_NAME" FROM "COMPANY_HR_IDM_DATA_V" WHERE "COMPANY_HR_IDM_DATA_V"."PK_PERSON_ID" = :arg0) "_SUB" WHERE ROWNUM <= 21) WHERE "_RN" > 0
I tried to put as much information as I could, can anyone please steer me in the right direction?