[Django]-ImportError while rendering: No module named app

3👍

if may caused by wsgi.py configuration issues in pythonanywhere,in local env,django handle python path and static files well.
According to this part in pythonanywhere deploy doc:

  1. adding the right path to sys.path in wsgi.py

assuming your Django settings file is at /home/my_username/projects/my_project/settings.py’

path = '/home/my_username/projects'
if path not in sys.path:
    sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'my_project.settings'
from my_project.myapp.models import Kitchen, Sink

please note:my_project prefix is needed.

2.static files should handle well

from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()

check this two points according to document should fix that

1👍

Had the exact same problem with my app… the issue turned out to be file permissions. If the app directory doesn’t have execute permissions, it failed to be imported.

Leave a comment