Hi Guys, This is the error I am getting:
(first_django_app) ➜ first_django_app git:(master) heroku run python manage.py loaddata books/fixtures.json Running python manage.py loaddata books/fixtures.json on ⬢ gotbooksapp... up, run.6617 (Free) Traceback (most recent call last): File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 82, in _execute return self.cursor.execute(sql) psycopg2.errors.ForeignKeyViolation: insert or update on table "books_book" violates foreign key constraint "books_book_user_id_4b809191_fk_auth_user_id" DETAIL: Key (user_id)=(1) is not present in table "auth_user". The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options) File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 78, in handle self.loaddata(fixture_labels) File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 131, in loaddata connection.check_constraints(table_names=table_names) File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/postgresql/base.py", line 285, in check_constraints cursor.execute('SET CONSTRAINTS ALL IMMEDIATE') File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 98, in execute return super().execute(sql, params) File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 66, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers return executor(sql, params, many, context) File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/app/.heroku/python/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 82, in _execute return self.cursor.execute(sql) django.db.utils.IntegrityError: Problem installing fixtures: insert or update on table "books_book" violates foreign key constraint "books_book_user_id_4b809191_fk_auth_user_id" DETAIL: Key (user_id)=(1) is not present in table "auth_user". I have done the following: rm -f db.sqlite3 run python manage.py makemigrations run python manage.py migrate I had to add all the information again as the database had been cleaned out I then implement fixtures.json locally I did a git add ., git commit -m and git push heroku master I did run heroku run python manage.py migrate I finally run python manage.py loaddata books/fixtures.json I still have the same errors again BR, Ejike Chiboka 08022224537; 08166516400 On Fri, Apr 23, 2021 at 7:28 PM Sujayeendra G <sgsujay.ach...@gmail.com> wrote: > > Hi, > > You can see IntegrityError: fixtures you are updating trying to find user > with user_id=1 which are not available in your db. Try to create one user > and migrate again. Or if the App is still in the development stage. Delete > DB and migrate again. It may work. > > Thank you > > Regards > Sujay > > > On Fri, 23 Apr 2021 at 17:25, ejike....@gmail.com <ejike.chib...@gmail.com> > wrote: > >> Good day All, >> >> I am trying to deploy my django app to heroku but i keep getting this >> error in the screenshot attached. >> >> Please can anyone assist in me in finding a solution to this and where >> the issue could be coming from. >> >> Looking forward to your replies. >> >> Thanks and BR, >> >> Ejike >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/7c7fd9ab-20a6-43f3-9793-06ea0f4220c6n%40googlegroups.com >> <https://groups.google.com/d/msgid/django-users/7c7fd9ab-20a6-43f3-9793-06ea0f4220c6n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAJ15Ob0pe9%3DpT56vqkbYNE_6sp5qYgts7aYtnCTVqfdaSOQ%2B6g%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAJ15Ob0pe9%3DpT56vqkbYNE_6sp5qYgts7aYtnCTVqfdaSOQ%2B6g%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADe59C_wKOARokYkrgh7kX6Lq1Y1mSoctSRgN27CDkKeRAUAog%40mail.gmail.com.