This is a project exploring the Django-Rest-Framework with Djoser.
Through the project, I created Function-based views, Class-based views, Class-based views for Serialized Models, Generic views for Serialized Models and Viewsets. In the final code, everything except the Viewsets is commented out. Relevant URLs and code can be uncommented to explore different functionality as well.
First, clone the repository and create a virtual environment. Install all dependencies and start the server.
git clone https://github.com/chouhanaryan/exploring-drf.git
cd .\exploring-drf\
pipenv shell
pipenv install
cd .\drf\
python manage.py runserver
(generated using Pygraphviz)
- Root
GET
/
Response - URLs of main API structure
- Login
POST
/auth/token/login/
Response - Returns authorization token
Body - Password, Email
- Logout (Authentication Required)
POST
/auth/token/logout/
Response - None
- Users (Authentication Required)
GET
/auth/users/
Response - Detailed list of all users
- Users (Authentication Required)
POST
/auth/users/
Response - Register a new user
Body - Username, First name, Last name, Email, Password, Re password
- Person (Authentication Required)
GET | POST | PUT | DELETE
/person/
Response - Detailed list of all people registered
Body - Name, Email, DOB, Age, ID (as and when required)
- Person (ID) (Authentication Required)
GET
/person/<id>/
Response - Details of specific person by ID
- House (Authentication Required)
GET | POST | PUT | DELETE
/house/
Response - Detailed list of all houses registered
Body - Loc, Owner (URL), pin (unique), ID (as and when required)
- House (ID) (Authentication Required)
GET
/house/<id>/
Response - Details of specific house by ID
To explore the API, use Postman or any other API development platforms.
Administrator login credentials:
email: [email protected]
password: admin
User login credentials:
email: [email protected]
/ [email protected]
password: Aryan123
Login using any of these by sending the appropriate request to the API, and you shall receive an authorization token. Now, include this token as a header (format: Authorization: Token <token>
) to send requests that require authorization.
The administrator credentials can also be used to manually add people, houses, users and generate tokens via the Django admin panel.
Documentation for additional functionality can be accessed at the Djoser docs.