From 0c8ec0f8d108ce7d57c18e083a17fe624690e514 Mon Sep 17 00:00:00 2001 From: gw3000 Date: Wed, 7 Jun 2023 18:36:54 +0200 Subject: [PATCH] first urls and simple views --- core/urls.py | 5 +++-- fbf/urls.py | 9 +++++++++ fbf/views.py | 14 ++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 fbf/urls.py diff --git a/core/urls.py b/core/urls.py index 3b2f61e..49b9f67 100644 --- a/core/urls.py +++ b/core/urls.py @@ -15,8 +15,9 @@ 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 path, include urlpatterns = [ - path('admin/', admin.site.urls), + path("bird/", include("fbf.urls")), + path("admin/", admin.site.urls), ] diff --git a/fbf/urls.py b/fbf/urls.py new file mode 100644 index 0000000..324056b --- /dev/null +++ b/fbf/urls.py @@ -0,0 +1,9 @@ +from django.urls import path + +from .views import bird_create, bird_all, bird_single + +urlpatterns = [ + path("create/", bird_create, name="fallen_bird_create"), + path("all/", bird_all, name="fallen_bird_all"), + path("/", bird_single, name="fallen_bird_single"), +] diff --git a/fbf/views.py b/fbf/views.py index 91ea44a..275035e 100644 --- a/fbf/views.py +++ b/fbf/views.py @@ -1,3 +1,13 @@ -from django.shortcuts import render +from django.shortcuts import render, HttpResponse -# Create your views here. + +def bird_create(request): + return HttpResponse("Create a bird") + + +def bird_all(request): + return HttpResponse("Show all Birds") + + +def bird_single(request, id): + return HttpResponse(f"Show bird with ID {id}")