Setup the Login Function and api route Here we have created a login function which handled the POST request and get username and password as params and then authenticate them if they are correct then return the token if they are correct else return the not found response. map the /api/login route with our function.
Read moreWhich authentication is best for Django REST Framework?
I personally would recommend a token-based authentication , so you don’t have to worry about clients intercepting user’s credentials.
Read moreHow do I authenticate in Django?
User authentication in Django
Read moreHow does Django REST Framework authentication work?
Authentication is the mechanism of associating an incoming request with a set of identifying credentials, such as the user the request came from, or the token that it was signed with . The permission and throttling policies can then use those credentials to determine if the request should be permitted.
Read moreHow do I create a custom user model in Django REST Framework?
Custom User model
Read moreHow do I start a Django REST Framework?
Start Using the API!
Read moreCan you build an API with Django?
Start a Django project First, we’re going to create a new Django project named rapid-api-practice. Then, within that project, we will create a new app called api. Although this may seem odd at first, the “Django way” is to house an app, or more than likely multiple apps, within a single “project.”
Read more