Add polls app with basic views and URL routing

This commit is contained in:
2025-12-10 21:03:51 -05:00
parent 620012392d
commit 384b2e7303
9 changed files with 34 additions and 2 deletions

View File

@@ -14,9 +14,11 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
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 include, path
urlpatterns = [
path('admin/', admin.site.urls),
path("admin/", admin.site.urls),
path("polls/", include("polls.urls")),
]

0
polls/__init__.py Normal file
View File

3
polls/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
polls/apps.py Normal file
View File

@@ -0,0 +1,5 @@
from django.apps import AppConfig
class PollsConfig(AppConfig):
name = 'polls'

View File

3
polls/models.py Normal file
View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
polls/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
polls/urls.py Normal file
View File

@@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index"),
]

9
polls/views.py Normal file
View File

@@ -0,0 +1,9 @@
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")
def index2(request):
return HttpResponse("Hello, world. You're at the polls index #2.")