diff --git a/DjangoTutorial/settings.py b/DjangoTutorial/settings.py index 4a2d7b5..be28851 100644 --- a/DjangoTutorial/settings.py +++ b/DjangoTutorial/settings.py @@ -37,6 +37,7 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'rest_framework', 'post', ] diff --git a/DjangoTutorial/urls.py b/DjangoTutorial/urls.py index 672010e..058e038 100644 --- a/DjangoTutorial/urls.py +++ b/DjangoTutorial/urls.py @@ -14,9 +14,11 @@ 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('post/', include('post.urls')), ] diff --git a/poetry.lock b/poetry.lock index 7d9404a..fd31b38 100644 --- a/poetry.lock +++ b/poetry.lock @@ -63,6 +63,21 @@ tzdata = {version = "*", markers = "sys_platform == \"win32\""} argon2 = ["argon2-cffi (>=19.1.0)"] bcrypt = ["bcrypt"] +[[package]] +name = "djangorestframework" +version = "3.15.1" +description = "Web APIs for Django, made easy." +category = "main" +optional = false +python-versions = ">=3.6" +files = [ + {file = "djangorestframework-3.15.1-py3-none-any.whl", hash = "sha256:3ccc0475bce968608cf30d07fb17d8e52d1d7fc8bfe779c905463200750cbca6"}, + {file = "djangorestframework-3.15.1.tar.gz", hash = "sha256:f88fad74183dfc7144b2756d0d2ac716ea5b4c7c9840995ac3bfd8ec034333c1"}, +] + +[package.dependencies] +django = ">=3.0" + [[package]] name = "filelock" version = "3.14.0" @@ -314,4 +329,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "6b01f6573f2c295286a2ddb883a8f7074655b8fcda9cda14721fd2416e58b15d" +content-hash = "a6b37f6efd3c1f966cd81c2319b65363f463c8c529e7237c08af36ccac430eba" diff --git a/post/urls.py b/post/urls.py new file mode 100644 index 0000000..d424010 --- /dev/null +++ b/post/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from post.views import hello_world + +urlpatterns = [ + path('hello/', hello_world), +] diff --git a/post/views.py b/post/views.py index 91ea44a..41f68cd 100644 --- a/post/views.py +++ b/post/views.py @@ -1,3 +1,5 @@ -from django.shortcuts import render +from django.http import JsonResponse -# Create your views here. + +def hello_world(request): + return JsonResponse({'message': 'Hello, world!'}) diff --git a/pyproject.toml b/pyproject.toml index e4ada1f..0ae77b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ readme = "README.md" [tool.poetry.dependencies] python = "^3.10" django = "^4.2" +djangorestframework = "^3.15.1" [tool.poetry.group.dev.dependencies] pre-commit = "^3.3.3"