$ python manage.py startapp polls
tree 실행하면 파일은 아래와 같다.
polls/ __init__.py admin.py apps.py migrations/ __init__.py models.py tests.py views.py
polls/views.py 을 수정한다.
from django.http import HttpResponse def index(request): return HttpResponse("Hello, world. You're at the polls index.")
polls/urls.py 을 수정한다.
from django.urls import path from . import views urlpatterns = [ path('', views.index, name='index'), ]
mysite/urls.py 를 수정한다.
from django.contrib import admin from django.urls import include, path urlpatterns = [ path('polls/', include('polls.urls')), path('admin/', admin.site.urls), ]
서버를 실행한다.
$ python manage.py runserver
참고 : https://docs.djangoproject.com/en/2.2/intro/tutorial01/#creating-the-polls-app