---Advertisement---
Django Microservices REST Framework

Django – REST Framework Interview Question-Answer

By smart_answer13

Updated on:

---Advertisement---

Q.1 If you are supporting writable nested representations, you need to add __________ method for saving multiple objects.

       A. .create() and .update()

       B. Nothing. Serializers are default writable

       C. .update()

       D. .create()

Ans : .create() and .update()


Q.2 Identify the core arguments of each serializer field class constructor.

       A. allow_null

       B. read_only

       C. write_only

       D. required

       E. All the options

Ans : All the options


Q.3 Serializer validation errors return __________ reponse by default.

       A. HTTP 400 Bad Request

       B. HTTP 500 Internal Server Error

       C. HTTP 404 Not Found

       D. None of the options

       E. All the options

Ans : HTTP 400 Bad Request


Q.4 Serializer fields are referred by using ________.

       A. model.FieldName

       B. serializers.<FieldName>

       C. FieldName

       D. All the options

Ans : serializers.<FieldName>


Q.5 To get multiple objects using ListSerializer, ________ option should be used.

       A. list=True

       B. many=True

       C. include(list)

       D. include(many)

Ans : many=True


Q.6 Individual fields on a serializer can include validators, by declaring them on the field instance. Is this statement true?

       A. True

       B. False

Ans : True


Q.7 Since the API chooses the content type of the response based on the client request, it will return an HTML-formatted representation of the resource in a web-browsable form. Is this statement correct?

       A. True

       B. False

Ans : True


Q.8 request.data handles arbitrary data and works for _____ HTTP methods.

       A. POST

       B. PUT

       C. PATCH

       D. All the options

Ans : All the options


Q.9 If a client sends malformed content, it will raise a ParseError. What catches the error and responds with a 400 Bad Request.

       A. APIView Class

       B. @api_view decorator and APIView class

       C. @api_view decorator

       D. web browser

       E. custom function

Ans : @api_view decorator and APIView class


Q.10 To render the serialized data of the response into the final response, the __________ method is called.

       A. .render()

       B. .data

       C. Response

       D. .content_type

Ans : .render()


Q.11 When you want an interface for returning content-negotiated Web API responses, you go for

       A. HttpResponse

       B. StreamingHttpResponse

       C. Response

       D. All the options

Ans : Response


Q.12 Identify the correct status code which indicates that the server is incapable of performing a request and errors out.

       A. HTTP_500_INTERNAL_SERVER_ERROR

       B. HTTP_503_SERVICE_UNAVAILABLE

       C. HTTP_502_BAD_GATEWAY

       D. HTTP_501_not_IMPLEMENTED

       E. All the options

Ans : All the options


Q.13 Identify the concrete view which extends the GenericAPIView and ListModelMixin

       A. DestroyAPIView

       B. RetrieveAPIView

       C. CreateAPIView

       D. ListAPIView

Ans : ListAPIView


Q.14 APIView uses HTTPRequest and HTTPResponse instances. Is this statement correct?

       A. True

       B. False

Ans : False


Q.15 Request objects treat JSON data and other media types in same way as dealing with form data. Is this statement correct?

       A. True

       B. False

Ans : True


Q.16 When you use @api_view based View, it uses default renderers, parsers and authentication classes. Is this statement correct?

       A. True

       B. False

Ans : True


Q.17 Authentication by itself won’t allow or disallow an incoming request, it simply identifies the credentials that the request was made with. Is this correct?

       A. True

       B. False

Ans : True


Q.18 Which is not a view action

       A. Retrieve

       B. Create

       C. List

       D. Delete

Ans : Delete


Q.19 Which class controls the pluggable aspects of API views

       A. .renderer_classes

       B. .permission_classes

       C. .authentication_classes

       D. All the options

Ans : All the options


Q.20 Which is not an HTTP handler method

       A. .get()

       B. .put()

       C. .list()

       D. .delete()

       E. .post()

Ans : .list()


Q.21 The default @api_view implementation accepts only GET method and responds with _______ for other methods.

       A. 406 Not Acceptable

       B. 405 Method Not Allowed

       C. 505 HTTP Version Not Supported

       D. 400 Bad Request

Ans : 405 Method Not Allowed


Q.22 Oauth authentication scheme can be established using which external package

       A. Django Oauth Toolkit

       B. Django REST Framework Oauth

       C. Django OAuth2 Consumer

       D. All the options

Ans : All the options


Q.23 Which statement is applicable for CSRF validation in REST Framework

       A. support both session and non-session based authentication to the same views

       B. not suitable for login views

       C. only authenticated requests require CSRF tokens

       D. anonymous requests may be sent without CSRF tokens

       E. All the options

Ans : All the options


Q.24 The authentication scheme that allows you to delegate authentication to your web server, which sets the REMOTE_USER environment variable is called ___________.

       A. Token Authentication

       B. Remote User Authentication

       C. Basic Authentication

       D. Session Authentication

Ans : Remote User Authentication


Q.25 Relational fields when rendered in a browsable API display a maximum of _____ items.

       A. 10000

       B. 1000

       C. 500

       D. 100

Ans : 1000


Q.26 Relational fields represent model relationships. They can be applied to _______.

       A. ForeignKey

       B. Reverse Relationships

       C. OnetoOneField

       D. ManytoManyField

       E. All the options

Ans : All the options


Q.27 Authentication by itself won’t allow or disallow an incoming request, it simply identifies the credentials that the request was made with. Is this correct?

       A. True

       B. False

Ans : True


Q.28 When permission classes are set through class attribute or decorators, it ignores the default settings in the settings.py file. Is this correct

       A. True

       B. False

Ans : False


Q.29 HyperlinkedModelSerializer includes id field by default

       A. True

       B. False

Ans : False


Q.30 To use Hyperlinked API, it is essential to name the URL pattern. Is this correct?

       A. True

       B. False

Ans : False


Q.31 Serializer Relationships can be represented using

       A. hyperlinking between entitities

       B. default string representation of the related entity

       C. unique identifying slug field on a related entity

       D. primary keys

       E. All the options

Ans : All the options


Q.32 What adds login and logout views for a browsable API,

       A. urlpatterns += [
  url(r’^api-auth/’, include(‘rest_framework.loginViews’)),
]

       B. urlpatterns += [
  url(r’^api-auth/’, include(‘rest_framework.login.urls’)),
]

       C. urlpatterns += [
  url(r’^api-auth/’, include(‘rest_framework.urls’)),
]

       D. urlpatterns += [
  url(r’^api-auth/’, include(‘rest_framework.login’)),
]

Ans : urlpatterns += [
  url(r’^api-auth/’, include(‘rest_framework.urls’)),
]


smart_answer13

---Advertisement---

Related Post

Zipkin-Jaeger Interview Question-Answer

Q.1 Which is responsible for sending spans to storage?        A. Transport        B. Collector        C. Component        D. ...

Weaveworks Interview Question-Answer

Q.1 Which of the following features offered by WeaveClouds?        A. Observability        B. VCS integration        C. none of the mentioned ...

Vaadin Unplugged Interview Question-Answer

Q.1 Which of the Programming Model is not supported by Vaadin?        A. Browser        B. Client Side        C. Server Side ...

Spring Boot Framework Interview Question-Answer Part – 2

Q.1 The annotation used to import additional configuration classes is ___________.        A. @Import        B. @Include        C. @EnableImport     ...

Leave a Comment