Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

891
Visualizações
Why am I getting a 'ProgrammingError: relation "auth_user" does not exist' exception when running tests?

Recently I've migrated a Django project from version 1.9.1 to 3.2.7.

Now I'm trying to write some new tests, and I'm getting this error:

# python manage.py test
Creating test database for alias 'default'...
Got an error creating the test database: database "test_django" already exists

Type 'yes' if you would like to try deleting the test database 'test_django', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
Traceback (most recent call last):
  File "/opt/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "auth_user" does not exist

I understand this is because currently I don't have any 'migrations' directory, as I cloned the git repo and the DB already existed when the Django project was running in version 1.9.1.

I've read:

  • This question.
  • Also this one.
  • Also this.

All of them recommend running migrations, but:

# python manage.py makemigrations 
No changes detected
# python manage.py makemigrations auth
No changes detected in app 'auth'

Again, I think this is because the DB schema already existed before upgrading to 3.2.

I cannot seem to solve the issue running the migrations approach.

Is there another way to solve this issue, or force to generate the migrations even if the DB already exist and is synced (and possible fake them)?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

If the error is because of the migrations you can skip the migration errors while running tests by using the following django library

django-test-without-migrations ( pip install django-test-without-migrations)

Install the library and add it in INSTALLED_APPS (settings.py)

Then run, python manage.py test --nomigrations 

refer:https://pypi.org/project/django-test-without-migrations/

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda