My setup:
I get the following error when I ru
You have not given any code so its difficult to understand your models relations. But can I guess that you have passed the ForeignKey model as an instance? Try to give it as a string
class MyModel(models.Model):
fk_field = models.ForeignKey('path.to.other.model') # same as from path.models import model
This usually works out. Hope it does for you too!
I had a similar issue with manage.py test
when I ran it in gitlab CI jobs, I was able to fix this by creating a variable called CI
in my base.py
settings file
base.py
"""
Set CI Variable to True when running: "manage.py test"
"""
CI = True
and in my settings.py
:
if CI:
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
return None # For Django 1.10+
MIGRATION_MODULES = DisableMigrations()
I've got same error beacuse one of my django applications have not migrations
directory. Try to watch carefully all your apps folders which are present in INSTALLED_APPS
.
This should be solved by running:
python manage.py migrate auth
python manage.py migrate app
python manage.py migrate
Got the same issue, and since it happens on ./manage.py test
, your migrations may be broken.
Since Django 1.7, there is a new setting called MIGRATION_MODULES
, in which you configure your app's migration modules.
Adding the following workaround in settings.py (found here) skips migrations on tests, and solved it for me:
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
return "notmigrations"
MIGRATION_MODULES = DisableMigrations()
python manage.py migrate auth
This works.