mumbleapi icon indicating copy to clipboard operation
mumbleapi copied to clipboard

Getting Foreign Key constraint failed error while running loaddata command

Open shukl08vk opened this issue 3 years ago • 6 comments

HI, I am getting this below error while loading the test JSON data using the command python manage.py loaddata articledata.json

ERROR:- raise dj_exc_value.with_traceback(traceback) from exc_value File "D:\Programming\Django\mumbleapi\env\lib\site-packages\django\db\backends\base\base.py", line 242, in _commit return self.connection.commit() django.db.utils.IntegrityError: FOREIGN KEY constraint failed

Please look into the issue. Also explain the problem due to which it occurs.

shukl08vk avatar Jun 14 '21 05:06 shukl08vk

did you created the superuser first ?

PraveenMalethia avatar Jun 14 '21 11:06 PraveenMalethia

did you created the superuser first ?

Yes, I followed the exact steps as it is there.

shukl08vk avatar Jun 14 '21 11:06 shukl08vk

did you created the superuser first ?

fetchdata.json file loaded smoothly but for the next two data, I am facing the same foreign key constraint error.

shukl08vk avatar Jun 14 '21 11:06 shukl08vk

okay ! let me see

PraveenMalethia avatar Jun 22 '21 02:06 PraveenMalethia

Same issue but I get it only when running "python manage.py loaddata discussiondata.json"

IlyaMichlin avatar Jul 31 '21 09:07 IlyaMichlin

The error seems to be caused by the tags field for some reason. Removing the tags from the discussiondata.json file solved the problem for me.

marianoesteban avatar Jan 09 '22 00:01 marianoesteban