The error occurs during migration. The following shows the complete traceback. Thanks. ------------------------------------ % python manage migrate WFK: BASE_DIR= /home/bill/django/wfkprojs/proj1 WFK: STATIC_PATH= /home/bill/django/wfkprojs/proj1/app_1/static/ WFK: MEDIA_ROOT= /home/bill/django/wfkprojs/proj1/app_1/media_root/ WFK: MEDIA_URL= /media_root/ Operations to perform: Apply all migrations: contenttypes, app_1, sessions, auth, admin Running migrations: Applying app_1.0003_auto_20141126_2333...Traceback (most recent call last): File "/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) psycopg2.ProgrammingError: column "date" cannot be cast automatically to type integer HINT: Specify a USING expression to perform the conversion.
The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python3.3/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.3/site-packages/django/core/management/__init__.py", line 377, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.3/site-packages/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/local/lib/python3.3/site-packages/django/core/management/base.py", line 338, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.3/site-packages/django/core/management/commands/migrate.py", line 160, in handle executor.migrate(targets, plan, fake=options.get("fake", False)) File "/usr/local/lib/python3.3/site-packages/django/db/migrations/executor.py", line 63, in migrate self.apply_migration(migration, fake=fake) File "/usr/local/lib/python3.3/site-packages/django/db/migrations/executor.py", line 97, in apply_migration migration.apply(project_state, schema_editor) File "/usr/local/lib/python3.3/site-packages/django/db/migrations/migration.py", line 107, in apply operation.database_forwards(self.app_label, schema_editor, project_state, new_state) File "/usr/local/lib/python3.3/site-packages/django/db/migrations/operations/fields.py", line 139, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File "/usr/local/lib/python3.3/site-packages/django/db/backends/schema.py", line 473, in alter_field self._alter_field(model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict) File "/usr/local/lib/python3.3/site-packages/django/db/backends/schema.py", line 626, in _alter_field params, File "/usr/local/lib/python3.3/site-packages/django/db/backends/schema.py", line 99, in execute cursor.execute(sql, params) File "/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py", line 81, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) File "/usr/local/lib/python3.3/site-packages/django/db/utils.py", line 94, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/usr/local/lib/python3.3/site-packages/django/utils/six.py", line 549, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: column "date" cannot be cast automatically to type integer HINT: Specify a USING expression to perform the conversion. On Tuesday, February 17, 2015 at 4:39:27 PM UTC-8, Joel Burton wrote: > > The error is probably in code you wrote that uses the date field. Can you > post the full traceback? That will let us see where the caller was that > created the problem. > > On Tuesday, February 17, 2015 at 3:13:30 PM UTC-5, tony....@gmail.com > wrote: >> >> 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. >> >> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f294ac0a-b409-4f7f-8b17-f169fbc9e81d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.