Refactor home page view to use a template
This commit is contained in:
parent
5157f05996
commit
35019b3e4b
3
lists/templates/home.html
Normal file
3
lists/templates/home.html
Normal file
@ -0,0 +1,3 @@
|
||||
<html>
|
||||
<title>To-Do lists</title>
|
||||
</html>
|
@ -4,8 +4,6 @@ from lists.views import home_page
|
||||
|
||||
# Create your tests here.
|
||||
class HomePageTest(TestCase):
|
||||
def test_home_page_returns_correct_html(self):
|
||||
def test_uses_home_page_template(self):
|
||||
response = self.client.get("/")
|
||||
self.assertContains(response, "<title>To-Do lists</title>")
|
||||
self.assertContains(response, "<html>")
|
||||
self.assertContains(response, "</html>")
|
||||
self.assertTemplateUsed(response, "home.html")
|
@ -1,6 +1,5 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
|
||||
# Create your views here.
|
||||
def home_page(request):
|
||||
return HttpResponse("<html><title>To-Do lists</title></html>")
|
||||
return render(request, "home.html")
|
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'lists',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
Loading…
Reference in New Issue
Block a user