djangoのモデルを作成して、管理サイトで予定を追加しようとすると以下のエラーが出ます。models.pyのscheduleTimeを消去して実行するとうまくいきます。タイムスタンプ?か何かが原因に思うのですが、調べてもよくわかりません。よろしくお願いします。
エラー内容
python
1psycopg2.errors.DatatypeMismatch: column "scheduleTime" is of type integer but expression is of type timestamp with time zone 2LINE 1: ... "schedule", "scheduleTime") VALUES (1, 'お花見', '2021-09-1... 3 ^ 4HINT: You will need to rewrite or cast the expression. 5 6The above exception was the direct cause of the following exception: 7 8 9django.db.utils.ProgrammingError: column "scheduleTime" is of type integer but expression is of type timestamp with time zone 10LINE 1: ... "schedule", "scheduleTime") VALUES (1, 'お花見', '2021-09-1... 11 ^ 12HINT: You will need to rewrite or cast the expression. 13
コード(models.py)
python
1from django.db import models 2from accounts.models import CustomUser 3 4class Calender(models.Model): 5 user = models.ForeignKey(CustomUser, verbose_name="ユーザー", on_delete=models.PROTECT) 6 schedule = models.CharField(verbose_name="予定", max_length=30, null=True, blank=True) 7 #scheduleTime = models.DateTimeField(verbose_name="日にち", auto_now=True) 8 9 class Meta: 10 verbose_name_plural = "予定表"
admin.py
python
1from django.contrib import admin 2 3# Register your models here. 4from calenderApp.models import Calender 5admin.site.register(Calender)
あなたの回答
tips
プレビュー