Re: [Django] #10827: django.auth create_permissions must clear the content type cache before creating permissions

69 views
Skip to first unread message

Django

unread,
Sep 13, 2011, 4:07:37 PM9/13/11
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------------+------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Milestone: | Component: contrib.auth
Version: SVN | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 1
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------+------------------------------
Changes (by orb@…):

* ui_ux: => 0
* easy: => 0


Comment:

I'm having this problem too. We worked around it by extending
TransactionTestCase so that _pre_setup() invokes
ContentType.objects.clear_cache(). I'd really love to see a solution to
this.

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 17, 2012, 3:23:07 PM5/17/12
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by jodym@…):

* cc: jodym@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:8>

Django

unread,
May 17, 2012, 3:42:52 PM5/17/12
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by anonymous):

A workaround based on comment 7 is available here:
http://djangosnippets.org/snippets/2752/

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:9>

Django

unread,
Jul 3, 2012, 10:29:58 AM7/3/12
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by gcc):

+1. This just bit us as well.

I think if flush is going to invalidate caches (which it appears to do),
then it should be sending a signal that allows holders of caches to
respond appropriately. So something like this in flush.py:

{{{
for app in set(all_models):
models.signals.post_flush.send(sender=app, app=app,
created_models=created_models, verbosity=verbosity,
interactive=interactive, db=db)
emit_post_sync_signal(set(all_models), verbosity, interactive, db)
}}}

Assuming a new signal `flush` which ContentTypeManager listens for, and
then flushes its cache.

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:10>

Django

unread,
Jul 3, 2012, 10:30:06 AM7/3/12
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by gcc):

* cc: chris+django@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:11>

Django

unread,
Feb 27, 2013, 4:32:35 PM2/27/13
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by rjalves):

* cc: rjalves@… (added)


Comment:

The attached file is a fresh django project created with Django 1.4.5
which allows reproducing the mentioned error.
NOTE: This is not reproducible with the sqlite backend (MySQL was not
tested but was reported to fail with InnoDB in other tickets #9207).

Ticket #9207 is closed as fixed but due to lack of reproducibility. From
the error it looks like a duplicate of the current.
The workaround described on comment 3 from #9207 also solves the problem
(putting contrib.contenttypes before contrib.auth in INSTALLED_APPS).

PS: I don't know if there's any reason why INSTALLED_APPS has the current
order but having django-admin.py invert the order could workaround this
problem.

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:12>

Django

unread,
Feb 27, 2013, 4:35:19 PM2/27/13
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by rjalves):

Another duplicate: #6259

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:13>

Django

unread,
Aug 17, 2013, 2:28:33 PM8/17/13
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by anonymous):

I think I have run into the same problem while trying to use Selenium to
test Django admin capabilities. When I try to update a user's permissions,
I get the FK error. You can see [my code and issue on
SO](http://stackoverflow.com/questions/18281137/selenium-django-gives-
foreign-key-error). So I think this is still a present bug in Django 1.5.1
/ MySQL.

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:14>

Django

unread,
Dec 30, 2013, 3:24:48 AM12/30/13
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by jorgecarleitao):

* cc: jorgecarleitao (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:15>

Django

unread,
Feb 26, 2014, 4:40:47 AM2/26/14
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by julen):

* cc: julenx@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:16>

Django

unread,
Aug 29, 2014, 6:04:38 PM8/29/14
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by jarus):

* cc: jarus (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:17>

Django

unread,
Aug 20, 2015, 5:20:53 AM8/20/15
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by guettli):

I think this bug is still alive in Django1.7.

I get this traceback:

{{{
File ".../django/core/management/__init__.py", line 385, in
execute_from_command_line
utility.execute()
File ".../django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File ".../django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File ".../django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File ".../django/core/management/commands/migrate.py", line 165, in handle
emit_post_migrate_signal(created_models, self.verbosity,
self.interactive, connection.alias)
File ".../django/core/management/sql.py", line 268, in
emit_post_migrate_signal
using=db)
File ".../django/dispatch/dispatcher.py", line 198, in send
response = receiver(signal=self, sender=sender, **named)
File ".../django/contrib/auth/management/__init__.py", line 117, in
create_permissions
Permission.objects.using(using).bulk_create(perms)
File ".../django/db/models/query.py", line 410, in bulk_create
self._batched_insert(objs_without_pk, fields, batch_size)
File ".../django/db/transaction.py", line 339, in __exit__
connection.commit()
File ".../django/db/backends/__init__.py", line 176, in commit
self._commit()
File ".../django/db/backends/__init__.py", line 145, in _commit
return self.connection.commit()
File ".../django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File ".../django/db/backends/__init__.py", line 145, in _commit
return self.connection.commit()

django.db.utils.IntegrityError: insert or update on table
"auth_permission" violates foreign key constraint
"auth_content_type_id_508cf46651277a81_fk_django_content_type_id"
DETAIL: Key (content_type_id)=(1) is not present in table
"django_content_type".


}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:18>

Django

unread,
Aug 20, 2015, 5:25:31 AM8/20/15
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by guettli):

The six years old patch solved the issue for me:

{{{
ContentType.objects.clear_cache()
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:19>

Django

unread,
Aug 20, 2015, 5:41:10 AM8/20/15
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by guettli):

A work around is this line in your migration:

{{{
from django.contrib.contenttypes.models import ContentType

class Migration(migrations.Migration):
operations = [
...,
migrations.RunPython(lambda apps, schema_editor:
ContentType.objects.clear_cache()),
]

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:20>

Django

unread,
Aug 24, 2015, 5:50:42 AM8/24/15
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by guettli):

I created a pull request: https://github.com/django/django/pull/5184

It includes a test. Thanks to Tim Graham for the support.

https://groups.google.com/d/msg/django-developers/CB4cGwBYo8o/7qcekYNeAgAJ

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:21>

Django

unread,
Nov 3, 2015, 7:19:21 PM11/3/15
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by peterbe):

I can confirm that this is still a bug in Django 1.7.
I can't speak of the PR because I haven't studied it but making sure the
order of the INSTALLED_APPS is right, as per
http://stackoverflow.com/a/18292090/205832 did solve it for me.

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:22>

Django

unread,
Nov 7, 2015, 6:05:10 AM11/7/15
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner: kvsn
Type: Bug | Status: assigned

Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by kvsn):

* status: new => assigned
* owner: nobody => kvsn


--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:23>

Django

unread,
Nov 10, 2015, 5:03:54 AM11/10/15
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner:
Type: Bug | Status: new

Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by kvsn):

* status: assigned => new
* owner: kvsn =>


Comment:

Don't forget to use a database that checks foreign key constraints instead
of the default sqlite when trying to reproduce this bug.

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:24>

Django

unread,
Nov 12, 2015, 1:03:28 AM11/12/15
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner:
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by teeberg):

* cc: teeberg (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:25>

Django

unread,
Jan 21, 2016, 3:41:28 AM1/21/16
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
------------------------------+------------------------------------
Reporter: seanl | Owner:
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by srkunze):

@guettli @timgraham

It just works. Nice. Thanks for that suggestion.

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:26>

Django

unread,
Jun 30, 2017, 9:16:35 PM6/30/17
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
--------------------------------+------------------------------------
Reporter: Sean Legassick | Owner: (none)

Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------

Comment (by Lynn Cyrin):

issue is still present in django 1.11.2

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:27>

Django

unread,
Oct 19, 2017, 4:10:13 AM10/19/17
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
--------------------------------+------------------------------------
Reporter: Sean Legassick | Owner: (none)
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------

Comment (by Michał Pasternak):

I am having this problem with Django 1.11.5 and purest with pytest-django


{{{
________________________________________________________________ ERROR at
teardown of test_foo
________________________________________________________________

self = <django.db.backends.postgresql.base.DatabaseWrapper object at
0x10ee8e630>

def _commit(self):
if self.connection is not None:
with self.wrap_database_errors:
> return self.connection.commit()
E psycopg2.IntegrityError: B����D: wstawianie lub
modyfikacja na tabeli "auth_permission" narusza klucz obcy
"auth_permission_content_type_id_2f476e4b_fk_django_co"
E DETAIL: Klucz (content_type_id)=(893) nie wyst��puje w
tabeli "django_content_type".

../../envs/django-bpp/lib/python3.6/site-
packages/django/db/backends/base/base.py:236: IntegrityError

The above exception was the direct cause of the following exception:

self = <django.test.testcases.TransactionTestCase testMethod=__init__>

def _post_teardown(self):
"""Performs any post-test things. This includes:

* Flushing the contents of the database, to leave a clean
slate. If
the class has an 'available_apps' attribute, post_migrate
isn't fired.
* Force-closing the connection, so the next test gets a clean
cursor.
"""
try:
> self._fixture_teardown()

../../envs/django-bpp/lib/python3.6/site-
packages/django/test/testcases.py:925:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _
../../envs/django-bpp/lib/python3.6/site-
packages/django/test/testcases.py:960: in _fixture_teardown
inhibit_post_migrate=inhibit_post_migrate)
../../envs/django-bpp/lib/python3.6/site-
packages/django/core/management/__init__.py:131: in call_command
return command.execute(*args, **defaults)
../../envs/django-bpp/lib/python3.6/site-
packages/django/core/management/base.py:330: in execute
output = self.handle(*args, **options)
../../envs/django-bpp/lib/python3.6/site-
packages/django/core/management/commands/flush.py:88: in handle
emit_post_migrate_signal(verbosity, interactive, database)
../../envs/django-bpp/lib/python3.6/site-
packages/django/core/management/sql.py:53: in emit_post_migrate_signal
**kwargs
../../envs/django-bpp/lib/python3.6/site-
packages/django/dispatch/dispatcher.py:193: in send
for receiver in self._live_receivers(sender)
../../envs/django-bpp/lib/python3.6/site-
packages/django/dispatch/dispatcher.py:193: in <listcomp>
for receiver in self._live_receivers(sender)
../../envs/django-bpp/lib/python3.6/site-
packages/django/contrib/auth/management/__init__.py:83: in
create_permissions
Permission.objects.using(using).bulk_create(perms)
../../envs/django-bpp/lib/python3.6/site-
packages/django/db/models/query.py:449: in bulk_create
obj_without_pk._state.db = self.db
../../envs/django-bpp/lib/python3.6/site-
packages/django/db/transaction.py:223: in __exit__
connection.commit()
../../envs/django-bpp/lib/python3.6/site-
packages/django/db/backends/base/base.py:262: in commit
self._commit()
../../envs/django-bpp/lib/python3.6/site-
packages/django/db/backends/base/base.py:236: in _commit
return self.connection.commit()
../../envs/django-bpp/lib/python3.6/site-packages/django/db/utils.py:94:


in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)

../../envs/django-bpp/lib/python3.6/site-packages/django/utils/six.py:685:
in reraise
raise value.with_traceback(tb)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _

self = <django.db.backends.postgresql.base.DatabaseWrapper object at
0x10ee8e630>

def _commit(self):
if self.connection is not None:
with self.wrap_database_errors:
> return self.connection.commit()
E django.db.utils.IntegrityError: B����D: wstawianie lub
modyfikacja na tabeli "auth_permission" narusza klucz obcy
"auth_permission_content_type_id_2f476e4b_fk_django_co"
E DETAIL: Klucz (content_type_id)=(893) nie wyst��puje w
tabeli "django_content_type".

../../envs/django-bpp/lib/python3.6/site-
packages/django/db/backends/base/base.py:236: IntegrityError

===================================================================== 29
tests deselected
=====================================================================
====================================================== 1 passed, 29
deselected, 1 error in 3.18 seconds
=======================================================
}}}

My package versions
{{{
pytest-base-url (1.4.1)
pytest-cov (2.5.1)
pytest-django (3.1.2)
pytest-html (1.16.0)
pytest-instafail (0.3.0)
pytest-localserver (0.3.6)
pytest-metadata (1.5.0)
pytest-splinter (1.8.5)
pytest-variables (1.7.0)

Django (1.11.5)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:28>

Django

unread,
Oct 19, 2017, 4:11:30 AM10/19/17
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
--------------------------------+------------------------------------
Reporter: Sean Legassick | Owner: (none)
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------

Comment (by Michał Pasternak):

Moving contenttypes apps before auth in INSTALLED_APPS fixed it.

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:29>

Django

unread,
Mar 19, 2018, 5:20:26 PM3/19/18
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
--------------------------------+------------------------------------
Reporter: Sean Legassick | Owner: (none)
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------

Comment (by Jared Proffitt):

Michał's fix work for me as well. If I move
`'django.contrib.contenttypes'` before `'django.contrib.auth'` in
`INSTALLED_APPS`, it works.

Would be nice to either have a fix that doesn't require that specific
order of apps, or some documentation mentioning you need the specific app
order.

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:30>

Django

unread,
May 28, 2018, 11:12:12 AM5/28/18
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
--------------------------------+------------------------------------
Reporter: Sean Legassick | Owner: (none)
Type: Bug | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------
Changes (by Claude Paroz):

* needs_tests: 1 => 0


Comment:

[https://github.com/django/django/pull/10001 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:31>

Django

unread,
Jun 3, 2018, 10:37:34 PM6/3/18
to django-...@googlegroups.com
#10827: django.auth create_permissions must clear the content type cache before
creating permissions
-------------------------------------+-------------------------------------
Reporter: Sean Legassick | Owner: Tim
| Graham <timograham@…>
Type: Bug | Status: closed
Component: contrib.auth | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* owner: (none) => Tim Graham <timograham@…>
* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"bec651a427fc032d9115d30c8c5d0e702d754f6c" bec651a]:
{{{
#!CommitTicketReference repository=""
revision="bec651a427fc032d9115d30c8c5d0e702d754f6c"
Fixed #10827 -- Ensured ContentTypes are created before permission
creation.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/10827#comment:32>

Reply all
Reply to author
Forward
0 new messages