'Django bulk create, ignore failed foreign keys?

Is there a way to ignore foreign key errors when doing a Model.objects.bulk_create and postgres? I'm aware of the ignore_conflicts=True flag and this seems to fix some errors, but I'm specifically dealing with data where the ForeignKey is not guaranteed to exist for one reason or another (such as the data being incomplete, deleted or more).

I'm aware that this can be done at the database level using FOREIGN_KEY_CHECKS but I just want this for a particular bulk_create call. What can I do here?



Solution 1:[1]

You might be passing undefined to Image source try using a condition at source to avoid passing undefined

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Manohar Gunduboina