I am following the tutorial on the Django website. I try and replicate this:
My code is as follows:
views.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")
def detail(request, film_id):
return HttpResponse("You're looking at film %s." % film_id)
def results(request, film_id):
response = "You're looking at the results of film %s."
return HttpResponse(response % question_id)
def vote(request, film_id):
return HttpResponse("You're commenting on film %s." % film_id)
films/urls.py
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
# url(r'^$', views.index, name='index'),
# ex: /polls/
path('', views.index, name='index'),
# ex: /films/5/
path('<int:film_id>/', views.detail, name='detail'),
# ex: /films/5/results/
path('<int:film_id>/results/', views.results, name='results'),
# ex: /films/5/vote/
path('<int:film_id>/vote/', views.vote, name='vote'),
]
With this I am getting ERR_CONNECTION_REFUSED. If I comment out all the paths leaving only the index url, and also comment out from django.urls import path
a page displays, but that is where I was at before trying to add more views.