7.5.2 A New View Function
parent
4d0f9a6976
commit
d2d72da60d
|
@ -49,10 +49,10 @@ class ListViewTest(TestCase):
|
|||
Item.objects.create(text="itemey 1")
|
||||
Item.objects.create(text="itemey 2")
|
||||
|
||||
response = self.client.get('/lists/the-only-list-in-the-world')
|
||||
response = self.client.get('/lists/the-only-list-in-the-world/')
|
||||
|
||||
self.assertIn('itemey 1', response.content.decode())
|
||||
self.assertIn('itemey 2', response.content.decode())
|
||||
self.assertContains(response, 'itemey 1')
|
||||
self.assertContains(response, 'itemey 2')
|
||||
|
||||
class ItemModelTest(TestCase):
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from django.http.request import HttpRequest
|
||||
from django.http.response import HttpResponse
|
||||
from django.shortcuts import redirect, render
|
||||
|
||||
from lists.models import Item
|
||||
|
@ -14,3 +12,7 @@ def home_page(request):
|
|||
return render(request=request,
|
||||
template_name='home.html',
|
||||
context={'items': items}) # pass items into template using render
|
||||
|
||||
def view_list(request):
|
||||
items = Item.objects.all()
|
||||
return render(request, 'home.html', {'items': items})
|
Loading…
Reference in New Issue