diff --git a/src/lists/templates/home.html b/src/lists/templates/home.html index 87e5ae9..34c2117 100644 --- a/src/lists/templates/home.html +++ b/src/lists/templates/home.html @@ -9,6 +9,8 @@ {% csrf_token %} -
+ + +
{{ new_item_text }}
\ No newline at end of file diff --git a/src/lists/tests.py b/src/lists/tests.py index 89d8566..31ff19b 100644 --- a/src/lists/tests.py +++ b/src/lists/tests.py @@ -17,4 +17,7 @@ class HomePageTest(TestCase): def test_can_save_a_POST_request(self): response = self.client.post('/', data={'item_text': 'A new list item'}) - self.assertIn('A new list item', response.content.decode()) \ No newline at end of file + self.assertIn('A new list item', response.content.decode()) + self.assertTemplateUsed(response, 'home.html') + + \ No newline at end of file diff --git a/src/lists/views.py b/src/lists/views.py index 2e0e7dd..8927dc9 100644 --- a/src/lists/views.py +++ b/src/lists/views.py @@ -4,10 +4,6 @@ from django.shortcuts import render # Create your views here def home_page(request): - """ - Using render function to take a request and name of the template to render - """ - - if request.method == 'POST': - return HttpResponse(request.POST['item_text']) - return render(request, 'home.html') \ No newline at end of file + return render(request=request, template_name='home.html', context={ + 'new_item_text': request.POST['item_text'], + }) \ No newline at end of file