[Django]-Django get_or_create not working as expected

2👍

You probably did some manual data importing, even if not, it’s not problem with django, but with database auto increment sequence. Django has a management command that generates sql command to reset those:

./manage.py sqlsequencereset myapp1 myapp2

If you are using PostgreSQL you can just pipe it in like that:

./manage.py sqlsequencereset myapp1 myapp2 | psql

or mysql if you are using MySQL, but I haven’t ried it.

👤lehins

Leave a comment