Add testapp and serve it at 'test/' URL
This commit is contained in:
parent
09cd3df774
commit
77df6e2aca
@ -15,8 +15,11 @@ Including another URLconf
|
|||||||
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.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import include, path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
# Add the path that our testapp should be served at
|
||||||
|
path("test/", include("testapp.urls")),
|
||||||
|
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
]
|
]
|
||||||
|
|||||||
0
testapp/__init__.py
Normal file
0
testapp/__init__.py
Normal file
3
testapp/admin.py
Normal file
3
testapp/admin.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
6
testapp/apps.py
Normal file
6
testapp/apps.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class TestappConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'testapp'
|
||||||
0
testapp/migrations/__init__.py
Normal file
0
testapp/migrations/__init__.py
Normal file
3
testapp/models.py
Normal file
3
testapp/models.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
3
testapp/tests.py
Normal file
3
testapp/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
6
testapp/urls.py
Normal file
6
testapp/urls.py
Normal 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
11
testapp/views.py
Normal 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)
|
||||||
Loading…
x
Reference in New Issue
Block a user