Can't run makemigrations after moving modules

Viewed 90

I've got a module named: validators.py located at ./project/app1/validators.py.

To use it, I have imported it inside one of my Models:

# app1/models.py
from .validators import validate_something

After a while, I decide to move this validators.py to a separated directory utils/ (which contains a __init__.py file), so I can use it in all my apps without referencing the app1.

Now it's located at: ./project/utils/validators.py.

After moving the module, I changed my import at the beginning of the Model:

# app1/models.py
from utils.validators import validate_something

Now that I want to create new migrations using manage.py makemigrations I'm getting this error:

File "project/app1/migrations/0001_initial.py", line 5, in <module>
    import app1.validators
ModuleNotFoundError: No module named 'app1.validators'

I can remove all migrations and regenerate them but I guess there should be another way to resolve this dependency issue.

0 Answers
Related