Url config. Map / to home_page view

This commit is contained in:
Ignacio 2024-10-23 13:16:53 -06:00
parent 285725ffdd
commit 1e2cc408de
2 changed files with 6 additions and 8 deletions

View File

@ -5,9 +5,7 @@ from lists.views import home_page
# Create your tests here. # Create your tests here.
class HomePageTest(TestCase): class HomePageTest(TestCase):
def test_home_page_returns_correct_html(self): def test_home_page_returns_correct_html(self):
request = HttpRequest() response = self.client.get("/")
response = home_page(request) self.assertContains(response, "<title>To-Do lists</title>")
html = response.content.decode("utf8") self.assertContains(response, "<html>")
self.assertIn("<title>To-Do lists</title>", html) self.assertContains(response, "</html>")
self.assertTrue(html.startswith("<html>"))
self.assertTrue(html.endswith("</html>"))

View File

@ -14,9 +14,9 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path 1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin
from django.urls import path from django.urls import path
from lists.views import home_page
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path("", home_page, name="home"),
] ]