Why new (custom) module in django app is not recognized?

I'm new to Django and I wanted to simply add some python files to one of my apps, in order to split code. If I create 'main.py' inside my app folder and import it from views.py (for istance) then I get:

File "/home/francesco/django-projects/my-env/my-projects/my-app/views.py", line 3, in <module>
    import main
ModuleNotFoundError: No module named 'main'

I couldn't find anything online, I don't know if it can't be done (if so, is there a workaround?) or if I'm doing something wrong (if so, what's the correct way?). I'm using django 4.1


solved changing import main to from . import main

Back to Top