본문 바로가기

Python/Django

(33)
[Django REST framework] 6. ViewSets & Routers https://www.django-rest-framework.org/tutorial/6-viewsets-and-routers/ 6 - Viewsets and routers - Django REST framework REST framework includes an abstraction for dealing with ViewSets, that allows the developer to concentrate on modeling the state and interactions of the API, and leave the URL construction to be handled automatically, based on common conventions. ViewSet c www.django-rest-frame..
[Django REST framework] 5. Relationships & Hyperlinked APIs https://www.django-rest-framework.org/tutorial/5-relationships-and-hyperlinked-apis/ 5 - Relationships and hyperlinked APIs - Django REST framework At the moment relationships within our API are represented by using primary keys. In this part of the tutorial we'll improve the cohesion and discoverability of our API, by instead using hyperlinking for relationships. Right now we have endpoints for..
[Django REST framework] 4. Authentication & Permissions https://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/ 4 - Authentication and permissions - Django REST framework Currently our API doesn't have any restrictions on who can edit or delete code snippets. We'd like to have some more advanced behavior in order to make sure that: Code snippets are always associated with a creator. Only authenticated users may create snipp w..
[Django REST framework] 3. Class-based Views https://www.django-rest-framework.org/tutorial/3-class-based-views/ 3 - Class based views - Django REST framework We can also write our API views using class-based views, rather than function based views. As we'll see this is a powerful pattern that allows us to reuse common functionality, and helps us keep our code DRY. We'll start by rewriting the root view as a cla www.django-rest-framework.o..
[Django REST framework] 2. Requests and Responses https://www.django-rest-framework.org/tutorial/2-requests-and-responses/#request-objects 2 - Requests and responses - Django REST framework From this point we're going to really start covering the core of REST framework. Let's introduce a couple of essential building blocks. REST framework introduces a Request object that extends the regular HttpRequest, and provides more flexible request pars w..
[Django REST framework] 1. Serialization https://www.django-rest-framework.org/api-guide/serializers/ Serializers - Django REST framework www.django-rest-framework.org https://www.django-rest-framework.org/tutorial/1-serialization/#setting-up-a-new-environment 1 - Serialization - Django REST framework This tutorial will cover creating a simple pastebin code highlighting Web API. Along the way it will introduce the various components th..
[Django Channels 2.4.0] Building simple Chat Server / 채팅 서버 구현 튜토리얼 part.3 Rewrite Chat Server as Asynchronous 비동기적으로 동작하게 Consumer 수정 Synchronous consumers은 어떤 특별한 코드 없이 Django models에 접근할 수 있는 등, regular synchronous I/O functions을 호출할 수 있기에 편리하다는 장점이 있다. 반면에, Asynchronous consumers은 request를 다룰 때, 추가적인 threads를 만들 필요가 없기에 higher level of performance를 제공한다. ChatConsumer은 async-native libraries(Channels and the channel layer)만을 사용하고, synchronous Django models에 접근하지 않는다. 그렇기에, 특별한 문제없이 asynchronous하게 바꿀 수..
[Redis 설치] Windows에 Redis 설치하는 법 / django channel layer에 사용하려다 헤맨 경험 Django channels layer 구현 중 Redis를 설치해야 했는데, 삽질을 엄청 했다.. 그 기록을 남긴다. 일단 내 환경은 Windows 10 HOME python 3.8.1 python virtualenv 처음에는 그냥 pip install redis만 하면 되는 줄 알았다가(redis PyPI) redis-server을 설치해야하는 것을 알았고, (redis quickstart) Redis는 공식적으로는 windows를 지원하지 않는다는 것을 알았다. (linux용 파일과 명령어..) 방법을 알기까지 삽질 좀 하면, 설치는 간단하다! windows용 redis 다운로드 마이크로소프트가 제공하는 공식 release 페이지에 들어가자 https://github.com/microsoftarch..