Skip to content Skip to sidebar Skip to footer

Notuniqueerror: Tried To Save Duplicate Unique Keys

I keep getting the above mentioned error. I have deleted the existing db field id which was set to unique. But on save I got the below exception raise NotUniqueError(message % unic

Solution 1:

If call list_indexes() it will show an unique index on the id field.

You need to drop the unique index on the id field in the collection as well using db.collection.dropIndex().

I am not sure if mongoengine provides a drop_index class method but you can do this from the shell.

Post a Comment for "Notuniqueerror: Tried To Save Duplicate Unique Keys"