0

In my models.py file I have:

class Book(models.Model):
    weeks_list = models.TextField(max_length=1000)

In my settings.py file I have:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'db_name',                      
        'USER': 'user',
        'PASSWORD': 'password',
        'HOST': 'localhost',
        'PORT': '',
    }
}

I have been using sqlite3 with a file called db.sqlite3. I wanted to switch to postgresql. When I try syncdb, I get the following error:

psycopg2.ProgrammingError: column "weeks_list" cannot be cast automatically to type date

HINT:  You might need to specify "USING weeks_list::date".

I'm not sure what to do.

0

1 Answer 1

0

go to the this.resolved problem

alter table "foo" alter column "date" type date using ("date"::text::date);
Sign up to request clarification or add additional context in comments.

5 Comments

Is it as follows?: alter table "db_name" alter column "weeks_list" type date using ("weeks_list"::text::date); And where am I supposed to type this?
type this command in postgresql command. for access to command i think must typing in command line psql. i don't use postgresql. you can search "postgresql command line"
I get ERROR: relation "db_name" does not exist. I tried making a new database and doing it again but still, same error.
I'm still really lost. I've commented out weeks_list from my models.py and when I try to migrate, I still get the error I posted at the beginning.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.