Add testapp and serve it at 'test/' URL

This commit is contained in:
Lucas Schumacher 2024-05-19 14:19:16 -04:00
parent 09cd3df774
commit 77df6e2aca
9 changed files with 36 additions and 1 deletions

View File

@ -15,8 +15,11 @@ Including another URLconf
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 = [
# Add the path that our testapp should be served at
path("test/", include("testapp.urls")),
path('admin/', admin.site.urls),
]

0
testapp/__init__.py Normal file
View File

3
testapp/admin.py Normal file
View File

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

6
testapp/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class TestappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'testapp'

View File

3
testapp/models.py Normal file
View File

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

3
testapp/tests.py Normal file
View File

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

6
testapp/urls.py Normal file
View File

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

11
testapp/views.py Normal file
View File

@ -0,0 +1,11 @@
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index_view(request):
# When this view is requested we will respond with this text
text = "Hello World! This is the testapp."
# Build a Http response with our text and send it to the requester
return HttpResponse(text)