1

I'm trying to run some simple tests with command: python manage.py test

When I do it, I get the error saying

File "/Users/petka/.local/share/virtualenvs/movie_platform-wu_Kht1X/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 394, in execute return Database.Cursor.execute(self, query) django.db.utils.OperationalError: no such table: auth_group

Anyone knows how to fix this?

movies_app/tests.py

    from django.test import TestCase

    class SmokeTest(TestCase):

    def test_bad_maths(self):
        self.assertEqual(1 + 1, 3)
1
  • Have you found a fix? I have the exact same error, but auth_group is no where in my code. Commented Jun 28, 2020 at 8:55

3 Answers 3

1

I tried deleting my db.sqlite3, migrations & pycache folder then running makemigrations, syncdb...etc as several posts suggest, but it threw the exact same error, sqlite3.OperationalError: no such table: auth_group.

Here's what worked for me: Comment out everything in urls.py and admin.py, the run makemigrations & migrate.

Details: Commenting out urls.py then running makemigrations threw the same error, but in the traceback it pointed to a line of code in admin.py that was trying to access or create a new instance in the db. I then commented out everything in admin.py and re-ran ./manage.py makemigrations & ./manage.py migrate in pipenv and it worked! The migrations folder was present when I did this (pulled it from git after deleting it in other attempts to solve the problem), so I'm guessing there's no need to delete it.

Sign up to request clarification or add additional context in comments.

Comments

0

have you migrated? if not then run the following commands

  1. python manage.py makemigrations
  2. python manage.py migrate

Comments

0

My fix was to execute the migration in the database that is used for tests. For some reason, you need to have it updated, even if it recreates everything.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.