Computer Science/BackEnd 57

장고 DRF #2 | Django REST framework Requests and Responses

Django REST framework Requests and Responses Request objects request.POST handles from data. request.data handles arbitrary data Response objects return Response(data) renders to content type Status codes HTTP 상태 코드를 숫자로 표현하기보다는 HTTP_400_BAD_REQUEST 식별자를 사용하는 편이 좋다. Wrapping API views REST 프레임워크에서 API뷰를 작성하는 두 개의 래퍼가 있다. @api_view 함수 기반 뷰로 작업하기 위한 데코레이터 APIView 클래스 기반 뷰로 작업하기 위한 클래스 래퍼는 입력이 잘못되었..

Django API #2 | A simple API with pure Django

Building APIs with Django and Django Rest Framework (readthedocs.org) The endpoints and the URLS 만들고자 하는 API는 다음과 같다. GET /polls/ Poll의 리스트를 가지고오는 API GET /polls// 지정한 id의 Poll을 가지고오는 API connecting urls to the views polls 앱에 views.py 파일로 polls_list 뷰와 polls_detail 뷰를 만들어준다. from django.shortcuts import render # Create your views here. def polls_list(request): pass def polls_detail(request, pk):..

장고 | 장고 공식 문서 내용 정리 #1-8 Getting started : writing your first Django app, part 7

첫 장고 앱 만들기 #7 admin 양식 커스텀하기 from django.contrib import admin from .models import Question, Choice # Register your models here. class QuestionAdmin(admin.ModelAdmin): fields=['pub_date', 'question_text'] admin.site.register(QuestionAdmin) admin.site.register(Choice) admin에서 모델을 보여주는 방식을 바꾸어주었다. from django.contrib import admin from .models import Question, Choice # Register your models here. cla..

Django API #1 | Setup, Models and Admin

Building APIs with Django and Django Rest Framework (readthedocs.org) Building APIs with Django and Django Rest Framework #2 Setup, Models and Admin 시작하기에 앞서 파이썬 가상환경을 활성화시켜주자. $ python3 -m venv pollsapi $ cd pollsapi/bin $ source activate Creating a project 앞선 튜토리얼에서 진행했던 것처럼 pollsapi 프로젝트를 시작해준다. $ django-admin startproject pollsapi Database setup 그냥 SQlite database를 사용할 것이다. DATABASES = { 'de..

Django API | #0 Introductions

Building APIs with Django and Django Rest Framework (readthedocs.org) 공식 문서를 읽다가 튜토리얼 부분을 넘어가니 양이 너무 방대해서 길을 잃었다. 특히 궁금한 API 부분에 집중한 책이나 자료를 찾다가 위 책을 발견했다. Building APIs with Django and Django Rest Framework! 분량이 적당하고 수준이 딱 맞을 것 같아 공부를 시작한다. 이 책을 다 공부한 뒤에는 Django for APIs 를 읽고, 그 다음에 블로그를 만드는 개인 프로젝트를 시작해보려 한다 Building APIs with Django and Django REST Framework #1 Introductions Who is this book ..

장고 공식 문서 #2-1 | Using Django : Models and databases

Django documentation contents | Django documentation | Django (djangoproject.com) Django documentation contents | Django documentation | Django Django The web framework for perfectionists with deadlines. Overview Download Documentation News Community Code Issues About ♥ Donate docs.djangoproject.com 모델과 데이터베이스 - 모델 빠른 사례 장고에서 모델은 데이터에 대해 알 수 있는 단일 정보 소스이다. 모델에 데이터의 필드와 동작(매소드)를 정의하고, 이 모델은 데이터베이..

장고 | 장고 공식 문서 내용 정리 #1-7 Getting started : writing your first Django app, part 6

첫 번째 장고 앱 작성하기, 6부 | 장고 문서 | 장고 (djangoproject.com) Writing your first Django app, part 6 | Django documentation | Django Django The web framework for perfectionists with deadlines. Overview Download Documentation News Community Code Issues About ♥ Donate docs.djangoproject.com 첫 장고 앱 만들기 6 장고에서는 JavaScript, CSS를 정적 파일(Static file)이라고 부른다. 앱 느낌 커스터마이즈하기 static/polls/style.css 파일을 생성하고 li a { col..