The Python Oracle

django.db.utils.IntegrityError: column "color_set_id" contains null values

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Puzzle4

--

Chapters
00:00 Django.Db.Utils.Integrityerror: Column &Quot;Color_set_id&Quot; Contains Null Values
01:55 Accepted Answer Score 2
02:14 Answer 2 Score 6
02:41 Thank you

--

Full question
https://stackoverflow.com/questions/4627...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #django #python3x #djangomodels #djangoadmin

#avk47



ANSWER 1

Score 6


Follow these steps

  • python manage.py migrate --fake

  • comment color_set

  • python manage.py makemigrations && python manage.py migrate
  • uncomment color_set
  • python manage.py makemigrations && python manage.py migrate



ACCEPTED ANSWER

Score 2


The problem is because you added null=True after creating the migration file. Follow these steps now.

1) Drop ColorSet & Product tables from your local table database.
2) Delete all the migration files you created for these `CharField to a ForeignKey` change
3) execute `python manage.py makemigrations`
4) execute 'python manage.py migrate'