Answer the question
In order to leave comments, you need to log in
How to resolve "relation does not exist" error in Django?
I am migrating a django project to a server.
It so happened that I have a lot of models. And to get around the 1600 columns limit from PostgreSQL, I split my models into 3 app/model files. Those. I have main, translations and translations2 applications. Each of them runs the django-modeltranslation library . I created 3 databases db, db_translations and db_translations2.
Added them to settings:
INSTALLED_APPS = [
...
'main',
'translations',
'translations2',
...
]
DATABASES = {
'default': {
...
'NAME': 'db',
..
},
'trans': {
...
'NAME': 'db_translations',
...
},
'trans2': {
...
'NAME': 'db_translations2',
...
}
}
python3 manage.py makemigrations main
python3 manage.py migrate main
python3 manage.py makemigrations translations
python3 manage.py migrate translations --database=trans
python3 manage.py makemigrations translations2
python3 manage.py migrate translations2 --database=trans2
django.db.utils.ProgrammingError: relation "translations_translations" does not exist
LINE 1: UPDATE "translations_translations" SET "open_ad_ru" = "trans...
Answer the question
In order to leave comments, you need to log in
Okay, I figured it out.
DATABASES = {
'default': { # Сюда будут записываться другие приложения, оставить "default"!!!
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db',
'USER': 'username',
'PASSWORD': 'pass',
'HOST': 'localhost',
'PORT': '',
},
't': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db_t',
'USER': 'username',
'PASSWORD': 'pass',
'HOST': 'localhost',
'PORT': '',
},
't2': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db_t2',
'USER': 'username',
'PASSWORD': 'pass',
'HOST': 'localhost',
'PORT': '',
},
't3': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db_t3',
'USER': 'username',
'PASSWORD': 'pass',
'HOST': 'localhost',
'PORT': '',
},
't4': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db_t4',
'USER': 'username',
'PASSWORD': 'pass',
'HOST': 'localhost',
'PORT': '',
},
't5': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db_t5',
'USER': 'username',
'PASSWORD': 'pass',
'HOST': 'localhost',
'PORT': '',
}
}
manage.py makemigrations <название приложения перевода>
manage.py migratе <название приложения перевода> --database=t<номер базы>
manage.py migratе
manage.py runserver <параметры>
*Создаем тестовый экземпляр*
manage.py update_translation_fields
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question