W | eb11 API (Application Punching Interface) API(Application Programming Interface)앱간 상호작용 인터페이스. REST, gRPC, SOAP, GraphQL, WebSocket.... 또 있나?REST와 RPC HTTP를 사용하는gRPC와 REST(Representational State Transfer)에 대해 알아보쟈Remote Procedure Call이름에서 보이듯, 원격에 있는 함수를 로컬에서 사용할 수 있게 하는 프로토콜.gRPC타겟이 되는 엔터티는 프로시저(함수). HTTP 2.0 사용. 데이터는 함수들 뒤에 있음.HTTP에서는 타겟 엔터티가 resource(즉, 데이터 엔터티 또는 모델)이고 그 뒤에 프로시저가 따라오는 것과는 상반됨.인터페이스 정의 언어로 Protocol Buffer를 사용. hands-.. 2025. 3. 17. Django: 테스트를 하는 테스트를 하는 테스트를 테스트 준비더보기- Ubuntu Server 22.04 - VSCode Insider - Remote SSH Extension - Postman Extension - Python 3.10 venv - Django 5.1.1 - SQLite 3.37.2pip install coverageUnit Test더보기polls_api/tests.pyfrom django.test import TestCasefrom polls_api.serializers import QuestionSerializer, VoteSerializerfrom django.contrib.auth.models import Userfrom polls.models import *class VoteSerializerTestCase(TestCase): .. 2024. 10. 11. Django CRUD: HTTP2 준비더보기- Ubuntu Server 22.04 - VSCode Insider - Remote SSH Extension - Postman Extension - Python 3.10 venv - Django 5.1.1 - SQLite 3.37.2# nothing to prep here유저 API 의 필드 표시 기능더보기polls_api/serializers.py# ...class UserSerializer(serializers.ModelSerializer): # rest/users 페이지에서 질문이 pk로 표시됨 # questions = serializers.PrimaryKeyRelatedField(many=True, queryset=Question.objects.all()) # 질문의 내.. 2024. 10. 10. Django CRUD: HTTP1 환경- Ubuntu Server 22.04 - VSCode Insider - Remote SSH Extension - Postman Extension- Python 3.10 venv- Django 5.1.1- SQLite 3.37.2준비# migration 안해도 되나 ??...source django_env/bin/activatemkdir test_proj/polls/templates/registrationtouch test_proj/polls/templates/registration/signup.htmltouch test_proj/polls_api/permissions.py# @test_proj/settings.py에 추가INSTALLED_APPS = ['polls_api.apps.PollsApiCo.. 2024. 10. 9. Django CRUD: Optimized 환경- Ubuntu Server 22.04 - VSCode Insider - Remote SSH Extension - Python 3.10 venv- Django 5.1.1- SQLite 3.37.2준비source django_env/bin/activate실행polls_api/views.py### generics 사용from rest_framework import genericsfrom polls.models import Questionfrom polls_api.serializers import QuestionSerializer# generics.xxxAPIView 안에 다 있었다 ...😤class QuestionList(generics.ListCreateAPIView): queryset = Qu.. 2024. 10. 9. Django CRUD: API 환경- Ubuntu Server 22.04 - VSCode Insider - Remote SSH Extension - Python 3.10 venv- Django 5.1.1- SQLite 3.37.2준비source django_env/bin/activate# @devcourse_django/test_proj/polls_apitouch urls.py실행test_proj/polls_api/views.pyfrom django.shortcuts import render, get_object_or_404from rest_framework import statusfrom rest_framework.response import Responsefrom polls.models import Questionfrom poll.. 2024. 10. 9. Django CRUD: Serialize 환경- Ubuntu Server 22.04 - VSCode Insider - Remote SSH Extension - Python 3.10 venv- Django 5.1.1- SQLite 3.37.2준비source django_env/bin/activate# 다른 OS는 모르겠는데 우분투는 이걸로 설치해야 import제대로 됨pip install djangorestframework# @test_proj/settings.py# INSTALLED_APPS 리스트에 'rest_framework' 추가# @devcourse_django/test_proj/python manage.py startapp polls_apitouch polls_api/serializers.py실행serializers.py# Model(.. 2024. 10. 8. Django CRUD: Admin 환경- Ubuntu Server 22.04 - VSCode Insider - Remote SSH Extension - Python 3.10 venv- Django 5.1.1- SQLite 3.37.2준비source django_env/bin/activate실행admin.py (Custom admin page)# polls/admin.py# The no-hassle way# admin.site.register(Question)# admin.site.register(Choice) # not needed anymore cuz inline# 질문 편집 페이지 내에 초이스 편집 기능 생성class ChoiceInline(admin.TabularInline): # StackedInline도 있음 # these.. 2024. 10. 8. 이전 1 2 다음