I uploaded my django project to pythonanywhere. But, I got some errors.
No module named 'api.urls'
in project/urls.py
project/urls.py
from django.contrib import admin
from django.conf.urls import include, url
from rest_framework.urlpatterns import format_suffix_patterns
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^api/', include('user.urls')),
url(r'^api/', include('api.urls')), # Error at here
]
urlpatterns = format_suffix_patterns(urlpatterns)
Only error at api.urls. But user.urls not. I can not understand why? "api" and "user" apps are the same root. But, "user.urls" worked correctly, "api.urls" is not.
My project structure:
├── project
│ ├── api
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── migrations
│ │ ├── models.py
│ │ ├── serializers.py
│ │ ├── tests.py
│ │ ├── urls.py
│ │ └── views.py
│ ├── manage.py
│ ├── media
│ ├── project
│ │ ├── __init__.py
│ │ ├── asgi.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ └── user
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ ├── models.py
│ ├── serializers.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
└── requirements.txt
pythonanywhere_com_wsgi.py
# +++++++++++ DJANGO +++++++++++
# To use your own django app use code like this:
import os
import sys
path = '/home/setname/example/project'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
# then:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Help me, Thanks.
I resolved this problem. In order to resolve this problem. You need use a new version of python then do pip install django