2016-01-20 4 views
0

Здравствуйте, я попробовал удалить модели, файлы миграции и найти что-то в стеке, но я ничего не нашел об этом.manage.py migration - error

Вы можете помочь мне с этой ошибкой? Я использую Django (1.8.8) на virtualenv

Ошибка из консоли:

Operations to perform: 
    Apply all migrations: core 
Running migrations: 
Rendering model states... DONE 
Applying core.0024_auto_20160120_1340... OK 
Applying core.0025_auto_20160120_1348...Traceback (most recent call last): 
File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.2\helpers\pycharm\django_manage.py", line 41, in <module> 
    run_module(manage_file, None, '__main__', True) 
File "C:\Program Files (x86)\Python35-32\Lib\runpy.py", line 182, in run_module 
    return _run_module_code(code, init_globals, run_name, mod_spec) 
File "C:\Program Files (x86)\Python35-32\Lib\runpy.py", line 96, in _run_module_code 
    mod_name, mod_spec, pkg_name, script_name) 
File "C:\Program Files (x86)\Python35-32\Lib\runpy.py", line 85, in _run_code 
    exec(code, run_globals) 
File "C:/Users/Bartek/PycharmProjects/CRM\manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\core\management\__init__.py", line 354, in execute_from_command_line 
    utility.execute() 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\core\management\__init__.py", line 346, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\core\management\base.py", line 394, in run_from_argv 
    self.execute(*args, **cmd_options) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\core\management\base.py", line 445, in execute 
    output = self.handle(*args, **options) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\core\management\commands\migrate.py", line 222, in handle 
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\migrations\executor.py", line 110, in migrate 
    self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\migrations\executor.py", line 148, in apply_migration 
    state = migration.apply(state, schema_editor) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\migrations\migration.py", line 115, in apply 
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\migrations\operations\fields.py", line 62, in database_forwards 
    field, 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\backends\sqlite3\schema.py", line 179, in add_field 
    self._remake_table(model, create_fields=[field]) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\backends\sqlite3\schema.py", line 77, in _remake_table 
    self.effective_default(field) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\backends\base\schema.py", line 211, in effective_default 
    default = field.get_db_prep_save(default, self.connection) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\models\fields\__init__.py", line 710, in get_db_prep_save 
    prepared=False) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\models\fields\__init__.py", line 1482, in get_db_prep_value 
    value = self.get_prep_value(value) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\models\fields\__init__.py", line 1461, in get_prep_value 
    value = super(DateTimeField, self).get_prep_value(value) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\models\fields\__init__.py", line 1317, in get_prep_value 
    return self.to_python(value) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\db\models\fields\__init__.py", line 1420, in to_python 
    parsed = parse_datetime(value) 
File "C:\Users\Bartek\dJangoEnvironment\lib\site-packages\django\utils\dateparse.py", line 93, in parse_datetime 
    match = datetime_re.match(value) 
TypeError: expected string or bytes-like object 

0025_auto_20160120_1348.py

# -*- coding: utf-8 -*- 

from __future__ import unicode_literals 

from django.db import migrations, models 

import datetime 


class Migration(migrations.Migration): 

    dependencies = [ 
      ('core', '0024_auto_20160120_1340'), 
    ] 

    operations = [ 
      migrations.RemoveField(
        model_name='clienthistory', 
        name='created_date', 
      ), 
      migrations.RemoveField(
        model_name='clienthistory', 
        name='last_modified', 
      ), 
      migrations.AddField(
        model_name='clienthistory', 
        name='content_x', 
        field=models.TextField(blank=True, null=True), 
      ), 
      migrations.AddField(
        model_name='clienthistory', 
        name='log_date', 
        field=models.DateTimeField(auto_now_add=True,default=2), 
        preserve_default=False, 
      ), 
      migrations.AlterField(
        model_name='order', 
        name='created', 
        field=models.DateTimeField(editable=False, default=datetime.datetime(2016, 1, 20, 13, 46, 44, 899932), help_text='Order created data'), 
      ), 
    ] 

Я использую Git, так что я откатить но у меня все еще есть эта ошибка.

+0

Как вы установки поля «матч»? –

+1

Можете ли вы разместить файл миграции 'core.0025_auto_20160120_1348'? –

ответ

1

В вашем поле даты журнала указано по умолчанию целое число, назначенное ему, это должна быть дата.

 migrations.AddField(
       model_name='clienthistory', 
       name='log_date', 
       field=models.DateTimeField(auto_now_add=True,default=2), # Change to a date 
       preserve_default=False, 
     ), 

Это также должно быть возможно только для удаления по умолчанию, так как auto_now_add делает это уже

+0

(Чтобы предотвратить дальнейшие проблемы с миграцией, это может потребоваться также применить внутри модели) – Sayse

+1

Спасибо за помощь. Это странно, потому что я не использовал атрибут по умолчанию в этом поле – Thaian