I have written a simple Django app (my first) that works with sqlite3 database.
I want to change to postgres, but when I run the Django 1.7 migration utility with the command
"python manage.py migrate"
I get the error:
psycopg2.ProgrammingError: column "date" cannot be cast automatically to type integer
Which is occuring in:
File "/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params
I am not sure how to track down the problem.
I am running Slackware Linux.
My models.py file is as follows:
====================================
from django.db import models
import datetime
# Create your models here.
class Location(models.Model):
class Meta:
unique_together = ("lat", "lng")
lat = models.DecimalField(max_digits=8, decimal_places=5)
lng = models.DecimalField(max_digits=8, decimal_places=5)
name = models.CharField(max_length=200, unique=True)
def __str__(self):
return "%s: %d %d" % (
self.name, self.lat, self.lng)
class Observation(models.Model):
date = models.DateField()
location = models.ForeignKey(Location)
observer = models.CharField(max_length=50)
temperature = models.FloatField(default=0.0)
photo = models.ImageField(default="tower.jpg", upload_to="uploaded_photos")
def __str__(self):
return self.observer
=========================================
The DATABASE part of my settings.py file is as follows
where I have commented-out the old sqlite3 part:
-----------------------------------------------------------------
DATABASES = {
# 'default': {
# # sqllite3
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# }
# For postgres:
#'django.db.backends.postgresql_psycopg2',
# USER, PASSWORD, HOST also needed
# Inside postgres, "CREATE DATABASE database_name"
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'app_1_db',
'USER': 'bill',
'PASSWORD': 'bill',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
--------------------------------------------------------------------------------
Please let me know if you have ideas.
Thanks.