DRF Interview Questions
DRF Interview Questions
1. What is an API?
An API is a set of definitions and protocols for building and integrating application
software. API stands for Application Programming Interface . APIs let your product or
service communicate with other products and services without having to know how they’re
implemented. This can simplify app development, saving time and money. The API is not the
database or even the server; it’s the code that governs the access point(s) for the server.
It’s sometimes referred to as a contract between an information provider and an information
user—establishing the content required from the consumer (the call) and the content required
by the producer (the response). For example, the API design for a weather service could
specify that the user supply a zip code and that the producer reply with a 2-part answer, the
first being the high temperature, and the second being the low.
4. What is an endpoint?
A web API has endpoints - URLs with a list of available actions (HTTP verbs) that expose
data (typically in JSON, which is the most common data format these days and the default for
Django REST Framework). The type of endpoint which returns multiple data resources is
known as a collection.
```python
# blog_project/settings.py
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated', # new
]
}
```
7. How to make custom permission classes?
To make custom permission class, create a file named `permissions.py` that imports
permissions at the top and then create your custom class, for example -
`IsAuthorOrReadOnly` which extends `BasePermission`, then we override
`has_object_permission`.