0

django.db.utils.IntegrityError: column "pinned" of relation "blog_post" contains null values

I migrated and did everything in localhost and Heroku server but I don't know how to solve this error.

Kronox
  • 15
  • 1
  • 7

1 Answers1

0

If column 'pinned' of blog__post is a non-nullable field, there is an entry in your database that is null for 'pinned'. Locate the entry and give it a value.

Use heroku run python manage.py makemigrations to create migrations on heroku server then you run heroku run python manage.py migrate to update your database tables.

John Bosco
  • 16
  • 2
  • Thanks but the thing is I don't even have the field pinned anymore in my localhost. On localhost, everything is working but Heroku I don't know how to delete that field. Just recently I made a new model and migrated the new model got registered in admin but when I click on that model is not working. So to migrate in Heroku we do "heroku run python manage.py migrate" and that's where pinned field has an error. If there is any command to delete this field using cmd I can go to Heroku and do that. Thanks a lot – Kronox Jun 02 '21 at 11:12
  • Use "heroku run python manage.py makemigrations" to update your database fields on heroku server before you run "heroku run python manage.py migrate"? If you have errors, post it let's have a look – John Bosco Jun 03 '21 at 12:28
  • Oh thanks a lot umm I did ur trick but I found out. I deleted my migrations and by the database on localhost and that seemed to fix the problem so I run the python manage.py makemigrations on Heroku and now it's working. Thanks a lot – Kronox Jun 05 '21 at 10:05
  • I am glad you fixed the issue. please mark my response as an answer if it helped you solve the problem. – John Bosco Jun 07 '21 at 10:48
  • Im sorry, but how do I make your answer – Kronox Jun 15 '21 at 06:12