This project is a simple REST API implemented using Django alongwith the Django Rest Framework. Authentication is handled using JSON web tokens. It provides the following functionalities:
- Login a user and generate access and refresh tokens.
- Refresh the access token using the refresh token.
- Creating, updating and deleting users profiles.
- Creating, updating and deleting posts.
The following tools and technologies are required for the project to work properly
-
Clone the repo using the following command
git clone <clone_url>
-
Navigate to the directory where the project is cloned and open terminal.
-
Run the following command to create a python virtual environment
python3 -m vevn ./env
-
Activate the newly create virtual environment by running the following command
source ./env/bin/activate
. Make sure to run this command otherwise the packages will be intalled in the global python environment and not the newly created one for this project. -
Run the following command to install the required packages
pip intall -r requirements.txt
-
Create a
.env
file in the root directory and paste the following contents.# APPLICATION SECRET_KEY=<random_secret_key> # DATABASE DATABASE_ENGINE=<database_engine> DATABASE_NAME=<database_name> DATABASE_USER=<database_user> DATABASE_PASSWORD=<database_user_password> DATABASE_HOST=<database_host> DATABASE_PORT=<database_port>
-
Run the following commands to install the migrations
python manage.py migrate
-
Run the following command to start the server
python manage.py runserver
To test the API endpoints a postman collection and environment is provided in the postman
directory. Kindly follow the steps to setup the collection and environment in Postman.
- Import the
Django REST API.postman_environment.json
file to load the environment and set that as the active environment. - Import the
Django REST API.postman_collection.json
file to load the collection for the available API endpoints on the server.
For linting the code pylint
has been used alongwith the autopep8
guidelines. To lint the code run the following command pylint ./*