Error when importing models into file, django

I'm trying to create a file for some of my database methods in a current django project. I need to import my file, but the import statement I'm using below (which follows the official Django example) is causing an error. Both and are already in appFolder, so is that the issue?

from appFolder.models import Class1,Class2,Class3 

Using only 'import models' didn't work when I ran it earlier. How can I resolve this? (I have also been running the file with the command './ test' if that's relevant)

If you have files in the same folder, you can use relative imports. Here is the example code:

from .models import Class1

There might be several problems but possibly you have missed the app inside the INSTALLED_APPS list in your settings file. That is a common mistake but relative imports work fine if you can manually trigger the tests.

Back to Top