Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango - Oracle backend error
    primarykey
    data
    text
    <p>I have the following model in Django:</p> <pre><code>class Event(models.Model): # some fields start_date = models.DateField() end_date = models.DateField() </code></pre> <p>I'm using Oracle 10g Database with Django 1.5 and cx_oracle 5.1.2. The issue here is when I try to create a new object in the admin interface (picking dates from the calendar), the following error is raised:</p> <pre><code>ORA-01843: not a valid month </code></pre> <p><code>syncdb</code> has created a <code>DATE</code> field in oracle for <code>start_date</code> and <code>end_date</code>. Does this look like a backend bug or am I doing something wrong?</p> <p>I do have other models with <code>DateTimeField()</code> and they work fine when I persist new objects, the issue looks related to <code>DateField</code> itself.</p> <p><strong>UPDATE:</strong> I have checked the backend implementation, and in <code>backends/oracle/base.py</code> lines 513 to 516:</p> <pre><code>cursor.execute( "ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'" " NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF'" + (" TIME_ZONE = 'UTC'" if settings.USE_TZ else '')) </code></pre> <p>Executing this statement allows an insert statement to have literal values for <code>DATE</code> fields. I have checked the query generated by the backend and it is inserting <code>'2013-03-20'</code> in <code>start_date</code> and <code>end_date</code>. The date matches <code>NLS_DATE_FORMAT</code>, so this in theory should work!</p> <p><strong>UPDATE</strong>: I believe my case is <a href="https://stackoverflow.com/questions/15396241/cx-oracle-ora-01843-not-a-valid-month-with-unicode-parameter">related to cx_oracle</a>.</p> <p><strong>UPDATE</strong>: Since I still don't have a definite answer (although I'm almost sure it's cx_oracle that's causing this issue), I changed my <code>DateField</code> into a <code>DateTimeField</code> which translates into oracle's <code>TIMESTAMP</code> and works perfectly fine.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload