7

I am using the custom user model which inherits from the AbstractBaseUser class. When I try to migrate after makemigrations command

django.db.utils.ProgrammingError: relation "custom_user_users" does not exist

This is happening since Django is trying to migrate other apps first which depends upon the custom user model. Even I tried to changing the order of the app which contains the custom user model in INSTALLED_APP but no luck.

I know I can force fully migrate custom_user model first then let Django migrate all other models. This solves the problem but during running test it runs the migration in order which Django decides.

How can I alter the order in which apps are migrated during test ? Any other way to solve this dependency problem ?

I am using Django 1.8

Jimit
  • 245
  • 3
  • 9
  • 3
    Have you had a look at https://docs.djangoproject.com/en/1.8/topics/migrations/#dependencies. To me, it seems to discuss this exact issue. – niconoe Apr 22 '15 at 13:26
  • I have checked out the link. And also think that that was the issue. But How should I go about solving it ? Is there any way in which I can decide the order in which application migrates during test command ? – Jimit Apr 22 '15 at 13:38
  • The following answer helped me (disable migrations in test) http://stackoverflow.com/questions/25161425/disable-migrations-when-running-unit-tests-in-django-1-7 – Galia Ladiray Weiss May 19 '15 at 11:59

2 Answers2

1

Put your your apps before Django apps in INSTALLED_APP in settings.py file

Vishal Mopari
  • 599
  • 7
  • 8
1

https://pypi.python.org/pypi/django-test-without-migrations adds a --nomigrations flag to manage.py test. Works like a charm.

Robin van Leeuwen
  • 2,625
  • 3
  • 24
  • 35