A
A
authoraytee2021-06-18 21:46:29
PostgreSQL
authoraytee, 2021-06-18 21:46:29

How to use date data type in django in postgresql?

In django model i have two fields with type DateField()

class Event(Model):
    EventName = models.CharField(max_length=50)
    PublicationDate = models.DateField()
    EventDate = models.DateField()


I run makemigrations - no problems, but on migrate it gives me:
django.db.utils.ProgrammingError: cannot cast type integer to date

And
LINE 1: ..." ALTER COLUMN "EventDate" TYPE date USING "EventDate"::date


I understand that the problem is that DateField from django and the data type for date in postgresql are of different types, how can they be connected?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2021-06-18
@authoraytee

The problem is that you already have a field named EventDate in your table, and it is never date.
Note that your migration is trying to do an ALTER COLUMN with a type change.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question