I changed my DB backends from sqlite3 to postgre. When I try to run migrate I have an error
MacBook-Pro-Oleg:avtofarm okorablev$ python3 manage.py migrate
Operations to perform: Synchronize unmigrated apps: messages, avtofarm, smart_selects, staticfiles, thumbnail Apply all migrations: contenttypes, admin, callboard, auth, sessions Synchronizing apps without migrations: Creating tables... Running deferred SQL... Installing custom SQL... Running migrations: Rendering model states... DONE Applying callboard.0004_auto_20150701_1609...Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) psycopg2.ProgrammingError: column "manufdate" cannot be cast automatically to type date 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 execute_from_command_line(sys.argv) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/init.py", line 338, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/init.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/base.py", line 393, in run_from_argv self.execute(*args, **cmd_options) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/base.py", line 444, in execute output = self.handle(*args, **options) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 221, in handle executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/migrations/executor.py", line 110, in migrate self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/migrations/executor.py", line 148, in apply_migration state = migration.apply(state, schema_editor) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/migrations/migration.py", line 115, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/migrations/operations/fields.py", line 201, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 484, in alter_field old_db_params, new_db_params, strict) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 636, in _alter_field params, File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 111, in execute cursor.execute(sql, params) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/utils.py", line 97, in exit six.reraise(dj_exc_type, dj_exc_value, traceback) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/utils/six.py", line 658, in reraise raise value.with_traceback(tb) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: column "manufdate" cannot be cast automatically to type date HINT: Specify a USING expression to perform the conversion.
Model
class Zip(models.Model):
category = models.ForeignKey(Category,null=True,verbose_name='Категория')
subcategory = ChainedForeignKey(SubCategory,chained_field="category",
chained_model_field="category",
show_all=False,
auto_choose=True,verbose_name='Подкатегория')
type = models.ForeignKey(Type,verbose_name='Состояние')
zipgroup = models.ForeignKey(ZipGroup,null=True,verbose_name='Группа запчастей')
ziptype = models.ForeignKey(ZipType,null=True,verbose_name='Вид запчасти')
cartype = models.ForeignKey(CarType,null=True,verbose_name='Тип авто')
carmodel = models.ForeignKey(CarModel,null=True,verbose_name='Модель транспорта')
carbodytype = models.ForeignKey(CarBodyType,null=True,verbose_name='Тип кузова')
catalognumber = models.CharField(max_length=100,null=True,blank=True,verbose_name='Номер по каталогу')
manufdate = models.CharField(max_length=4,null=True,verbose_name='Год выпуска')
title = models.CharField(max_length=100,verbose_name='Заголовок объявления')
description = models.TextField(null=True,verbose_name='Описание')
price = models.IntegerField(verbose_name='Цена')
user = models.ForeignKey(User,verbose_name='Пользователь')
creation_date = models.DateTimeField('date published')
is_sell = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
likes = models.IntegerField(default=0)
manufdate
column in your postgresql table defined? Sounds like you have adate
column and you needchar(4)
. – tcarobruce