Opened 5 years ago
Closed 5 years ago
#30884 closed Bug (invalid)
Possible bug using bulk_create for the user model
Reported by: | Conrad | Owned by: | nobody |
---|---|---|---|
Component: | Utilities | Version: | 2.2 |
Severity: | Normal | Keywords: | bulk_create |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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
Change History (2)
comment:1 by , 5 years ago
Component: | Uncategorized → Utilities |
---|
comment:2 by , 5 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |