4.3.1 Refactoring to Use a Template
parent
4f7cb1bb5a
commit
89224c9928
|
@ -0,0 +1,3 @@
|
||||||
|
<html>
|
||||||
|
<title>To-Do lists</title>
|
||||||
|
</html>
|
|
@ -23,5 +23,5 @@ class HomePageTest(TestCase):
|
||||||
response = home_page(request) #2
|
response = home_page(request) #2
|
||||||
html = response.content.decode('utf8') #3
|
html = response.content.decode('utf8') #3
|
||||||
self.assertTrue(html.startswith('<html>')) #4
|
self.assertTrue(html.startswith('<html>')) #4
|
||||||
self.assertIn('<title>To-Do list</title>', html) #5
|
self.assertIn('<title>To-Do lists</title>', html.strip()) #5
|
||||||
self.assertTrue(html.endswith('</html>')) #4
|
self.assertTrue(html.strip().endswith('</html>')) #4
|
|
@ -4,5 +4,8 @@ from django.shortcuts import render
|
||||||
|
|
||||||
# Create your views here
|
# Create your views here
|
||||||
def home_page(request):
|
def home_page(request):
|
||||||
# return HttpResponse('<html><title>To-Do lists</title></html>')
|
"""
|
||||||
return HttpResponse('<html><title>To-Do list</title></html>')
|
Using render function to take a request and name of the template to render
|
||||||
|
"""
|
||||||
|
|
||||||
|
return render(request, 'home.html')
|
|
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'lists'
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
Loading…
Reference in New Issue