7.4 Iterating Towards the New Design

This commit is contained in:
Jason Zhu 2020-11-10 23:56:56 +11:00
parent 0d2e2de364
commit e59776035b
2 changed files with 2 additions and 2 deletions

View File

@ -28,7 +28,7 @@ class HomePageTest(TestCase):
response = self.client.post('/', data={'item_text': 'A new list item'}) response = self.client.post('/', data={'item_text': 'A new list item'})
self.assertEqual(response.status_code, 302) self.assertEqual(response.status_code, 302)
self.assertEqual(response['location'], '/') self.assertEqual(response['location'], '/lists/the-only-list-in-the-world')
def test_only_saves_items_when_necessary(self): def test_only_saves_items_when_necessary(self):
self.client.get('/') self.client.get('/')

View File

@ -8,7 +8,7 @@ from lists.models import Item
def home_page(request): def home_page(request):
if request.method == 'POST': if request.method == 'POST':
Item.objects.create(text=request.POST['item_text']) Item.objects.create(text=request.POST['item_text'])
return redirect('/') return redirect('/lists/the-only-list-in-the-world')
items = Item.objects.all() # get objects from database (model) items = Item.objects.all() # get objects from database (model)
return render(request=request, return render(request=request,