Reputation:
I'm new to Django, so this might be a simple mistake. I've created a project and added a few separate apps. Everything seems to be working locally, but as soon as I deploy it to Heroku, I get the following error: No module named 'myapp.api.urls'
Project structure:
website
|____myapp
| |_____api
| | |_____urls.py
| | |_____views.py
| |
| |_____homepage
| | |_____urls.py
| | |_____views.py
| |
| |_____mailing
| | |_____urls.py
| | |_____views.py
| |
| |_____settings.py
| |_____urls.py
| |_____wsgi.py
|
|_____manage.py
|_____Procfile
|_____requirements.txt
|_____runtime.txt
Procfile:
web: gunicorn myapp.wsgi --log-file -
settings.py (not entire file content):
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ALLOWED_HOSTS = ['127.0.0.1', 'myapp.herokuapp.com']
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp.api',
'myapp.homepage',
'myapp.mailing',
]
ROOT_URLCONF = 'myapp.urls'
WSGI_APPLICATION = 'myapp.wsgi.application'
API urlpatterns:
urlpatterns = [
path('account/register/', ApiAccountRegisterView.as_view()),
path('account/login/', ApiAccountLoginView.as_view()),
]
MyApp urlpatterns:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('myapp.api.urls')),
path('', include('myapp.homepage.urls'))
]
Any idea what I'm doing wrong? I've searched online but couldn't find anything to help me solve this issue. Any help would be appreciated!
Upvotes: 0
Views: 74
Reputation:
Managed to figure out what's causing the issue. I didn't know that Heroku doesn't deal with git submodules (especially private submodules). I removed the submodules from the repo and add the files to the main repo. Deployed it again and now everything is working. Thanks for the suggestions. Appreciate the help!
Upvotes: 2
Reputation: 487
Updates to the Python buildpack mean that the PYTHONPATH and PYTHONHOME config vars being set on the app may introduce this issue.
Firstly, check if these are present with
heroku config
To fix the issue, you can unset them like so:
heroku config:unset PYTHONHOME -a website
heroku config:unset PYTHONPATH -a website
Upvotes: 0