its my installed apps :
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'leadgenerator',
'leadgenerator.apps.ui',
'leadgenerator.apps.accounts',
'leadgenerator.apps.instagram',
'leadgenerator.apps.BorseBots',
'leadgenerator.apps.TelegramBorse',
'leadgenerator.apps.Utils',
'leadgenerator.apps.Blog',
'leadgenerator.apps.Crypto',
'channels',
'multiselectfield',
'django_redis',
'django_filters',
'extra_views',
'django_select2',
'compressor',
'django_celery_beat',
'crispy_forms',
'django_tables2',
'ckeditor',
'ckeditor_uploader',
# 'leadgenerator.ckeditor5',
'leadgenerator.rolepermissions',
'rolepermissions',
# login and login_as
'loginas',
'allauth',
'allauth.account',
'allauth.socialaccount',
'phonenumber_field',
# blog
'modelcluster',
'taggit',
# end blog
'imagekit',
'pwa'
]
and i used user in models :
from django.contrib.auth.models import User as djangoUser
class BlogPost(models.Model):
author = models.ForeignKey(djangoUser, on_delete=models.CASCADE, related_name='blog_posts', verbose_name=_('Author'))
migration now is 0013
when i use backward migrate like this :
migrate Blog 0011
error happend :
ValueError: The field Blog.BlogPost.author was declared with a lazy reference to 'auth.user', but app 'auth' isn't installed.
also i do not have AUTH_USER_MODEL
in settings.py
also i can not remove data base because have so many data on it.
what is problem??
using django2.2 python3.7 postgresql
the problem was in migrations dependencies
no where imported auth
so i add below code in some of the first Blog
migrations
and error solved
Blog/migrations/0003....py # file name
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
...
]
actually if you see this error on other your_app just add some of migrations of your_app to dependencies like as below:
dependencies = [
('accounts', '0012_auto_20200730_1818'),
...
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With