Задать вопрос
  • Почему возникает ошибка при миграции в Django?

    @slavamarkov2 Автор вопроса
    FulTupFul,
    Applying vk_create_request.0003_auto_20190601_1844...Traceback (most recent call last):
    File "manage.py", line 21, in
    main()
    File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\core\management\base.py", line 364, in execute
    output = self.handle(*args, **options)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\core\management\base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\core\management\commands\migrate.py", line 234, in handle
    fake_initial=fake_initial,
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\db\migrations\executor.py", line 245, in apply_migration
    state = migration.apply(state, schema_editor)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\db\migrations\migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\db\migrations\operations\fields.py", line 112, in database_forwards
    field,
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\db\backends\base\schema.py", line 447, in add_field
    self.execute(sql, params)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\db\backends\base\schema.py", line 137, in execute
    cursor.execute(sql, params)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\db\backends\utils.py", line 99, in execute
    return super().execute(sql, params)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\db\backends\utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\psycopg2\_json.py", line 78, in getquoted
    s = self.dumps(self.adapted)
    File "C:\Users\vyach\PycharmProjects\mdata\venv\lib\site-packages\django\contrib\postgres\fields\jsonb.py", line 27, in dumps
    return json.dumps(obj, **options)
    File "C:\Program Files\Anaconda\lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
    File "C:\Program Files\Anaconda\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
    File "C:\Program Files\Anaconda\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
    File "C:\Program Files\Anaconda\lib\json\encoder.py", line 180, in default
    o.__class__.__name__)
    TypeError: Object of type 'datetime' is not JSON serializable

    И миграции

    Migrations for 'vk_create_request':
    vk_create_request\migrations\0011_auto_20190601_1948.py
    - Change Meta options on vkgroup
    - Change Meta options on vkgrouprequests
    - Add field count_posts to vkgrouprequests
    - Add field data to vkgrouprequests
    - Add field date_time_request to vkgrouprequests
    - Add field file_path to vkgrouprequests