﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30884	Possible bug using bulk_create for the user model	Conrad	nobody	"I am trying to create a lot of users for testing my Django application. I've used this method on other models and it works, but here it doesn't. When executed it states the error below. The latest Django version (2.2.6) was used. The documentation states:[https://docs.djangoproject.com/en/2.2/ref/models/querysets/#bulk-create]

''(...) setting the ignore_conflicts parameter to True tells the database to ignore failure to insert any rows that fail constraints such as duplicate unique values''.


My Code:

    
{{{
def draftUser(i):
        return User(username='Testguy' + str(i), first_name=randomString(7), last_name=randomString(5))
    
    user_cache = []
    
    for i in range(1, 10000):
        user_cache(draftUser(i))
    
    User.objects.bulk_create(user_cache, ignore_conflicts=True)
}}}

The last line of the error code:
**django.db.utils.IntegrityError: UNIQUE constraint failed: auth_user.username**


I've asked this question on Stack Overflow, but nobody seems to have an answer, so I think it might be a bug?
[https://stackoverflow.com/questions/58398338/django-ignore-conflicts-doesnt-work-for-user-model]"	Bug	closed	Utilities	2.2	Normal	invalid	bulk_create		Unreviewed	0	0	0	0	0	0
