Django

Django REST Framework

Serializers, ViewSets, routers, authentication, permissions, pagination, filtering, throttling, versioning

30 면접 질문·
Mid-Level
1

What is Django REST Framework (DRF)?

답변

Django REST Framework is a powerful and flexible toolkit for building Web APIs with Django. It provides features like serialization, authentication, permissions, pagination and automatic documentation. DRF has become the de facto standard for building RESTful APIs in Python with Django, thanks to its browsable interface and reusable components.

2

What is the main role of a Serializer in DRF?

답변

A Serializer in DRF converts complex objects like Django model instances into native Python data types that can then be easily rendered to JSON or XML. It also handles validation of incoming data and deserialization to transform JSON data into Python objects. Serializers are at the core of DRF and allow defining the data representation of the API.

3

What is the difference between Serializer and ModelSerializer?

답변

ModelSerializer is a subclass of Serializer that automatically generates fields based on the associated Django model. It automatically creates validators, implements default create() and update() methods, and significantly reduces boilerplate code. Serializer requires manually defining each field and create/update methods, offering more control but requiring more code.

4

How to define which fields to include in a ModelSerializer?

5

How to add custom validation on a specific field in a Serializer?

+27 면접 질문

다음 면접을 위해 Django을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기