头图

Error description

The error is as follows

> python manage.py test tweets
..............
  File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\mysql\base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\cursors.py", line 206, in execute
    res = self._query(query)
  File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\cursors.py", line 319, in _query
    db.query(q)
  File "C:\Users\17293\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\connections.py", line 259, in query
    _mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'test_d_twitter_db.tweets_tweet' doesn't exist")
PS C:\Users\17293\Desktop\Coder\Python\Django\twitter> python .\manage.py makemigrations

The data table is created by the unit test itself, is it manually created?
So this error made me confused at first

solution

Execute the following command

python manage.py makemigrations

Just execute the unit test command

python manage.py test tweets

No need to execute

python manage.py migratie

universe_king
3.4k 声望680 粉丝