This is a Django REST framework project that allows users to create, update, share, and delete notes, as well as view the version history of the notes.
-
clone this repository or download it as a zip file.
-
To install the required packages, run the following command in the project directory:
pip install -r requirements.txt
-
Fill the postgreSQL DB credentials in .
envfile or if want to use the SQLITE then comment out the line from92and comment in lines from99in settings.py file -
To set up the database, run the following commands:
python manage.py makemigrations
python manage.py migrate
- To
TEST, run the following commands:
python manage.py test notes
To create a superuser account, run the following command and follow the prompts:
python manage.py createsuperuser
- To run the development server, run the following command:
python manage.py runserver
To use the API endpoints, you need to have a valid user account and an authentication token. You can use the admin panel or the signup endpoint to create a user account, and the login endpoint to get the token.
BASE_URL/register/: This endpoint allows you to register a new user account. It accepts a POST request with the following json data:
JSON
{
"username": "<username>",
"email": "<email>",
"password": "<password>"
}
BASE_URL/login/: This endpoint allows you to log in as an existing user and get the authentication token. It accepts a POST request with the following json data:
JSON
{
"username": "<username>",
"password": "<password>"
}
You can use any HTTP client, such as Postman or curl, to send requests to the API endpoints. You need to include the authentication token in the header of your requests, using the following format:
Authorization: Token <token>
where <token> is the token you received from the login endpoint.
/notes/create POST: This endpoint allows you to create a new note. It accepts a POST request with the following json data:
JSON
{
"title": "<title>",
"content": "<content>"
}
/notes/<int:id> GET: This endpoint allows you to retrieve a specific note by its id.
id: The id of the note you want to access. It must be an integer value, such as 1, 2, 3, etc.
/notes/<int:id> PUT or PATCH | DELETE: This endpoint allows you to update, or delete a specific note by its id.
For the PUT or PATCH request, the following json data is required:
JSON
{
"title": "<title>",
"content": "<content>"
}
/notes/<int:id>/share POST: This endpoint allows you to share a note with other users. It accepts a POST request with the following json data:
JSON
{
"users": [<users>]
}
where
<id>is the id of the note you want to share, and<users>is a list of usernames or emails of the users you want to share the note with.
/notes/version-history/int:id/ GET: This endpoint allows you to get the version history of a note by its id. It accepts a GET request.