﻿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
30751	IntegrityError with TransactionTestCase and serialized_rollback=True.	Ray Tham	nobody	"I experienced the same issue in #23727 (which is marked as fixed)

{{{
Traceback (most recent call last):
  File ""/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py"", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint ""django_content_type_app_label_model_76bd3d3b_uniq""
DETAIL:  Key (app_label, model)=(admin, logentry) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File ""/usr/local/lib/python3.6/site-packages/django/test/testcases.py"", line 267, in __call__
    self._pre_setup()
  File ""/usr/local/lib/python3.6/site-packages/django/test/testcases.py"", line 938, in _pre_setup
    self._fixture_setup()
  File ""/usr/local/lib/python3.6/site-packages/django/test/testcases.py"", line 987, in _fixture_setup
    connections[db_name]._test_serialized_contents
  File ""/usr/local/lib/python3.6/site-packages/django/db/backends/base/creation.py"", line 133, in deserialize_db_from_string
    obj.save()
  File ""/usr/local/lib/python3.6/site-packages/django/core/serializers/base.py"", line 223, in save
    models.Model.save_base(self.object, using=using, raw=True, **kwargs)
  File ""/usr/local/lib/python3.6/site-packages/django/db/models/base.py"", line 779, in save_base
    force_update, using, update_fields,
  File ""/usr/local/lib/python3.6/site-packages/django/db/models/base.py"", line 870, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File ""/usr/local/lib/python3.6/site-packages/django/db/models/base.py"", line 908, in _do_insert
    using=using, raw=raw)
  File ""/usr/local/lib/python3.6/site-packages/django/db/models/manager.py"", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File ""/usr/local/lib/python3.6/site-packages/django/db/models/query.py"", line 1186, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File ""/usr/local/lib/python3.6/site-packages/django/db/models/sql/compiler.py"", line 1332, in execute_sql
    cursor.execute(sql, params)
  File ""/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py"", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File ""/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py"", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File ""/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py"", line 84, in _execute
    return self.cursor.execute(sql, params)
  File ""/usr/local/lib/python3.6/site-packages/django/db/utils.py"", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File ""/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py"", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint ""django_content_type_app_label_model_76bd3d3b_uniq""
DETAIL:  Key (app_label, model)=(admin, logentry) already exists.
}}}

I am currently using this as a workaround:
{{{
TEST_NON_SERIALIZED_APPS = ['django.contrib.contenttypes', 'django.contrib.auth']
}}}"	Bug	closed	Testing framework	dev	Normal	needsinfo	APITransactionTestCase		Unreviewed	0	0	0	0	0	0
