c0caDJ
c0caDJ

Reputation: 43

Why isn't Heroku's Postgresql updating according to Django's models.py?

Currently I'm running into issues with my models.py and Postgresql. The site is deployed on Heroku using Postgresql and the problem is models.py. Currently, I have models.py as a models.Charfield() and it works fine with sqlite, but when I deployed it to production, Postgresql still reports that it's a models.IntFied(). And because it's an integer field it won't allow for characters for some reason. Originally, I had it as a integerfield but decided to change to charfield, yet it still won't change to charfield. Solutions I've tried: resetting the database on heroku, deleting and recreating the database on heroku.

Any help is appreciated, Thanks

This is the line for my Charfield in my models.py

This is the error for Django admin reporting an integer error.

Upvotes: 1

Views: 54

Answers (2)

Luqman Shofuleji
Luqman Shofuleji

Reputation: 21

I normally follow the steps in this order:

  1. Ensure that your database changes have all been committed with git add and commit commands

  2. Reset the heroku database, Run {heroku pg:reset DATABASE_URL}

  3. Push your current changes to heroku with {git push heroku master}

  4. Launch the heroku terminal {heroku run bash}

  5. On the heroku terminal run {python manage.py migrate}

Upvotes: 1

Danizavtz
Danizavtz

Reputation: 3270

To sync your models to your database relational schema, you have to run the command:

python manage.py makemigrations
python manage.py migrate

Upvotes: 1

Related Questions