Modified home page template. Added more FT and UT
This commit is contained in:
@@ -4,9 +4,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<h1>Your To-Do list</h1>
|
||||
<input id="id_new_item" placeholder="Enter a to-do item" />
|
||||
<form method="POST">
|
||||
<input name="item_text" id="id_new_item" placeholder="Enter a to-do item" />
|
||||
{% csrf_token %}
|
||||
</form>
|
||||
<table id="id_list_table">
|
||||
|
||||
<tr><td>1: {{ new_item_text }}</td></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@@ -6,4 +6,9 @@ from lists.views import home_page
|
||||
class HomePageTest(TestCase):
|
||||
def test_uses_home_page_template(self):
|
||||
response = self.client.get("/")
|
||||
self.assertTemplateUsed(response, "home.html")
|
||||
|
||||
def test_can_save_a_POST_request(self):
|
||||
response = self.client.post("/", data={"item_text": "A new list item"})
|
||||
self.assertContains(response, "A new list item")
|
||||
self.assertTemplateUsed(response, "home.html")
|
@@ -1,5 +1,10 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
|
||||
# Create your views here.
|
||||
def home_page(request):
|
||||
return render(request, "home.html")
|
||||
return render(
|
||||
request,
|
||||
"home.html",
|
||||
{"new_item_text": request.POST.get("item_text", "")},
|
||||
)
|
Reference in New Issue
Block a user