Ошибка при миграции django и PostgreSQL

я создал модели django. Пытаюсь сделать миграции на PostgreSQL, но выдается ошибка, связанная с updated_date и timestamp.

django.db.utils.ProgrammingError: ОШИБКА:  привести тип integer к timestamp with time zone нельзя
LINE 1: ...TYPE timestamp with time zone USING "updated_date"::timestam...

Уже очень долго мучаюсь, но вообще нет вариантов, как решить эту ошибку.

models.py

from django.db import models
from django_currentuser.db.models import CurrentUserField
class Docs(models.Model):
    title = models.CharField('Заголовок', max_length=100)
    created_date = models.DateTimeField('Дата создания', auto_now_add=True)
    updated_date = models.DateTimeField('Дата последнего изменения', auto_now=True, auto_now_add=False)
    created_by = CurrentUserField(verbose_name="Создал", on_delete=models.CASCADE, related_name="docs_created_by")
    updated_by = CurrentUserField(verbose_name="Последнее изменение", on_update=True, related_name="docs_updated_by")

    class Meta:
        verbose_name = "документ"
        verbose_name_plural = "Документы"

class DocsScan(models.Model):
    doc = models.ForeignKey(Docs, on_delete=models.CASCADE)
    image = models.ImageField('Скан документа', upload_to='additional_edu/scans/%Y/%m/%d/%H-%M-%S/')

    class Meta:
        verbose_name = "скан"
        verbose_name_plural = "Сканы"

admin.py

from django.contrib import admin
from .models import *
# Register your models here.

class AdminDocsScan(admin.StackedInline):
    model = DocsScan
    max_num = 10
    extra = 0

@admin.register(Docs)
class AdminDocs(admin.ModelAdmin):
    
    inlines = [AdminDocsScan,]

    fieldsets = (
        (
            None, {
                'fields': ('title',)
            }
        ),
        (
            'Дополнительная информация', {
                "classes": ["collapse"],
                "fields": (
                    'created_date',
                    'updated_date',
                    'created_by',
                    'updated_by'
                )
            }
        )
    )

    list_display = ('title', 'created_date')
    list_display_links = ('title', 'created_date')
    readonly_fields = ('created_date', 'updated_date')

settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': '********',
        "USER": "********",
        "PASSWORD": "********",
        "HOST": "********",
        "PORT": "5432",
    }
}

Ошибка

(.env) PS C:\Users\huawei\Desktop\Проекты\kitt_kiosk\kitt_kiosk> py .\manage.py migrate 
C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django_currentuser\db\models\fields.py:65: UserWarning: You passed an argument to CurrentUserField that will be ignored. Avoid args and following kwargs: default, null, to.
  warnings.warn(self.warning)
System check identified some issues:

WARNINGS:
?: (ckeditor.W001) django-ckeditor bundles CKEditor 4.22.1 which isn't supported anmyore and which does have unfixed security issues, see for example https://ckeditor.com/cke4/release/CKEditor-4.24.0-LTS . You should consider strongly switching to a different editor (maybe CKEditor 5 respectively django-ckeditor-5 after checking whether the CKEditor 5 license terms work for you) or switch to the non-free CKEditor 4 LTS package. See https://ckeditor.com/ckeditor-4-support/ for more on this. (Note! This notice has been added by the django-ckeditor developers and we are not affiliated with CKSource and were not involved in the licensing change, so please refrain from complaining to us. Thanks.)
Operations to perform:
  Apply all migrations: additional_edu, admin, auth, contenttypes, main, news, sessions, social_media
Running migrations:
  Applying additional_edu.0003_docs_updated_by_alter_docs_updated_date...Traceback (most recent call last):
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\backends\utils.py", line 103, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.CannotCoerce: ОШИБКА:  привести тип integer к timestamp with time zone нельзя
LINE 1: ...TYPE timestamp with time zone USING "updated_date"::timestam...
                                                             ^


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\kitt_kiosk\manage.py", line 22, in <module>
    main()
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\kitt_kiosk\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\core\management\__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\core\management\base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\core\management\base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\core\management\base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\core\management\commands\migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\migrations\executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\migrations\executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\migrations\executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\migrations\migration.py", line 132, in apply
    operation.database_forwards(
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\migrations\operations\fields.py", line 235, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\backends\base\schema.py", line 880, in alter_field
    self._alter_field(
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\backends\postgresql\schema.py", line 288, in _alter_field
    super()._alter_field(
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\backends\base\schema.py", line 1137, in _alter_field
    self.execute(
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\backends\postgresql\schema.py", line 48, in execute
    return super().execute(sql, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\backends\base\schema.py", line 201, in execute
    cursor.execute(sql, params)
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\backends\utils.py", line 122, in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\backends\utils.py", line 79, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\backends\utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\backends\utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\huawei\Desktop\Проекты\kitt_kiosk\.env\Lib\site-packages\django\db\backends\utils.py", line 103, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.ProgrammingError: ОШИБКА:  привести тип integer к timestamp with time zone нельзя
LINE 1: ...TYPE timestamp with time zone USING "updated_date"::timestam...
Вернуться на верх