Cannot add foreign key constraint when applying migrations

30 views
Skip to first unread message

Esben Bugge

unread,
May 11, 2018, 5:33:01 AM5/11/18
to django-filer
Hi guys

I am trying to install filer v. 1.3.2. I have installed dependencies and applied their migrations:

Django 1.8.4
django-mptt 0.7
easy_thumbnails 2.3
django-polymorphic 1.3.1
Pillow 2.9.0

When I apply the migrations for filer I get this error for the 0001_initial migration:

django.db.utils.IntegrityError: (1215, 'Cannot add foreign key constraint')

Looking at the migration, I found that the problem occurs when creating foreign keys to my user model, fx. for the FolderPermission model:

('user', models.ForeignKey(related_name='filer_folder_permissions', verbose_name='user', blank=True, to=settings.AUTH_USER_MODEL, null=True))

If I remove lines that try to create foreign keys to the user model, the migration is applied correctly. I use a custom user model called email_username and the users are found in the email_username_user table. I have verified (by printing the variable when applying the migration) that setting.AUTH_USER_MODEL is correct when the migration is applied. I don't get why the migration cannot create foreign keys to this table. Any ideas?
Reply all
Reply to author
Forward
0 new messages