I'm trying to bulk create some entries using bulk_create() method of Django in the DB table. On the final step where I'm passing the created list over there getting an error TypeError: int() argument must be a string, a bytes-like object or a number, not 'tuple' and due to this obviously no records are getting saved.
Below is the code through which I'm trying to save the records in the DB table.
Class method
@classmethod
def mark_all_added(cls, id: int, spec_id: int) -> None:
spec_ids = set(
cls.objects.filter(spec_id=spec_id)
.values_list("id")
)
through_objects = [
cls.added_by.through(id=id, spec_id=sid)
for sid in spec_ids
]
cls.added_by.through.objects.bulk_create(through_objects) # getting error on this line
Could someone please help in highlighting my mistake or tell me how to resolve this issue while saving bulk records. I know I have a done a silly mistake but am unable to trace it. Any kind of would be much appreciated. Thanks in advance.
cls.added_by.through(id=id, spec_id=sid)? socls.added_by.through(id=id, spec_id=sid),.values_list, it thus turns out you provided enough information.