I just start learning Python3.x from scratch. in the tutorial of django 2.0, I am stuck with this question. please help me to solve the problem.
as a module, the following code works:
[directory]
mydir
|
+-test.py
+-test2.py
======================
[test.py]
import test2
test2.say()
======================
[test2.py]
def say():
print("hey")
but in django tutorial_01, (https://docs.djangoproject.com/en/2.0/intro/tutorial01/)
[directry]
polls/
__init__.py
admin.py
apps.py
migrations/
__init__.py
models.py
tests.py
urls.py
views.py
======================
[poll/urls.py]
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
import command does not work without from .
, even though views.py exists in the same directory.
Error message says ModuleNotFoundError: No module named 'views'
Could you explain why this kind of error occurs?
Thank you in advance!