ImportError for django-simple-history in VS Code: "Import 'simple_history.models' could not be resolvedPylance"

30 Views Asked by At

I'm currently working on a Django project and want to use django-simple-history to track changes on my models. However, I'm facing an issue with importing the HistoricalRecord model from simple_history.models.

Whenever I try to import it in my code, Visual Studio Code underlines the import statement and shows the error message "Import 'simple_history.models' could not be resolvedPylance".

Here are the steps I've taken to troubleshoot the issue:

  • I activated my virtual environment where django-simple-history is installed and then using pip freeze, I confirmed that django-simple-history==3.5.0 is listed.
  • I also used pip show django-simple-history to ensure the package details are correct, and it shows the expected information.
  • I deleted the virtual environment and recreated it, but the problem persists.
  • I checked the location where the virtual environment saves the library-specific data (venv\Lib\site-packages\simple_history), and I can see the HistoricalRecords model there.

Despite these efforts, I'm still unable to resolve the import error in VS Code.

Could anyone suggest what might be causing this issue and how I can fix it? Any help or guidance would be greatly appreciated.

Here is the error: (https://i.stack.imgur.com/mzpZQ.png)

Thank you!

0

There are 0 best solutions below