Follow these steps to run this Django project using Docker. Docker allow us to create a containerized environment for your application, making it portable and easy to manage.
- Docker installed on your system.
cd /path/to/your/project/directory
docker build -t book-writer-app .
docker run -d --name book-writer-container -p 8000:8000 book-writer-app
docker stop book-writer-container
docker rm book-writer-container
docker rmi book-writer-app
Represents books in the system.
Field | Type | Description |
---|---|---|
title |
CharField | The title of the book. |
author |
ForeignKey | The author of the book (linked to User model). |
collaborators |
ManyToManyField | Collaborators on the book (linked to User model). |
Represents sections within a book. Sections can be nested within other sections.
Field | Type | Description |
---|---|---|
title |
CharField | The title of the section. |
book |
ForeignKey | The book to which the section belongs (linked to Book model). |
Represents subsections within a section.
Field | Type | Description |
---|---|---|
title |
CharField | The title of the subsection. |
section |
ForeignKey | The section to which the subsection belongs (linked to Section model). |
parent_subsection |
ForeignKey | Parent sub section to which this sub section is nested (self-referential). |
Method: POST
Authentication: Not required
Description: Register a new user.
Request Body:
username
(string, required): The username of the new user.email
(string, required): The email address of the new user.password
(string, required): The password of the new user.
Response:
201 Created
: If the user is successfully registered.400 Bad Request
: If the request data is invalid.
Method: POST
Authentication: Not required
Description: Log in as an existing user.
Request Body:
username
(string, required): The username of the user.password
(string, required): The password of the user.
Response:
200 OK
: If the user is successfully logged in.- Response includes tokens for authentication:
refresh
: Refresh token.access
: Access token.
- Response includes tokens for authentication:
401 Unauthorized
: If the provided credentials are invalid.
Method: GET
Authentication: Required
Permissions: Authenticated users can access.
Description: Get a list of all books.
Response:
200 OK
: Successful response with a list of books.401 Unauthorized
: If the user is not authenticated.
Method: POST
Authentication: Required
Description: Create a new book.
Request Body:
title
(string, required): The title of the new book.
Response:
201 Created
: If the book is successfully created.400 Bad Request
: If the request data is invalid.
Method: GET
Authentication: Required
Permissions: Only the author or collaborator can access.
Description: Get details of a specific book.
Response:
200 OK
: Successful response with book details.404 Not Found
: If the book with the specified ID does not exist.403 Forbidden
: If the user does not have permission.
Method: PUT
Authentication: Required
Permissions: Only the author or collaborator can access.
Description: Update details of a specific book.
Request Body:
title
(string, required): The updated title of the book.
Response:
200 OK
: If the book is successfully updated.400 Bad Request
: If the request data is invalid.404 Not Found
: If the book with the specified ID does not exist.403 Forbidden
: If the user does not have permission.
Method: DELETE
Authentication: Required
Permissions: Only the author can access.
Description: Delete a specific book.
Response:
204 No Content
: If the book is successfully deleted.404 Not Found
: If the book with the specified ID does not exist.403 Forbidden
: If the user does not have permission.
Method: POST
Authentication: Required
Permissions: Only the author can create sections for a book.
Description: Create a new section.
Request Body:
book
(integer, required): The ID of the book to which the section belongs.title
(string, required): The title of the new section.
Response:
201 Created
: If the section is successfully created.400 Bad Request
: If the request data is invalid.
Method: GET
Authentication: Required
Permissions: Only the author or collaborator can access.
Description: Get details of a specific section.
Response:
200 OK
: Successful response with section details.404 Not Found
: If the section with the specified ID does not exist.403 Forbidden
: If the user does not have permission.
Method: PUT
Authentication: Required
Permissions: Only the author or collaborator can access.
Description: Update details of a specific section.
Request Body:
title
(string, required): The updated title of the section.
Response:
200 OK
: If the section is successfully updated.400 Bad Request
: If the request data is invalid.404 Not Found
: If the section with the specified ID does not exist.403 Forbidden
: If the user does not have permission.
Method: DELETE
Authentication: Required
Permissions: Only the author can access.
Description: Delete a specific section.
Response:
204 No Content
: If the section is successfully deleted.404 Not Found
: If the section with the specified ID does not exist.403 Forbidden
: If the user does not have permission.
Method: POST
Authentication: Required
Permissions: Only the author can create subsections for a section in a book.
Description: Create a new subsection.
Request Body:
section
(integer, required): The ID of the section to which the subsection belongs.title
(string, required): The title of the new subsection.
Response:
201 Created
: If the subsection is successfully created.400 Bad Request
: If the request data is invalid.
Method: GET
Authentication: Required
Permissions: Only the author or collaborator can access.
Description: Get details of a specific subsection.
Response:
200 OK
: Successful response with subsection details.404 Not Found
: If the subsection with the specified ID does not exist.403 Forbidden
: If the user does not have permission.
Method: PUT
Authentication: Required
Permissions: Only the author or collaborator can access.
Description: Update details of a specific subsection.
Request Body:
title
(string, required): The updated title of the subsection.
Response:
200 OK
: If the subsection is successfully updated.400 Bad Request
: If the request data is invalid.404 Not Found
: If the subsection with the specified ID does not exist.403 Forbidden
: If the user does not have permission.
Method: DELETE
Authentication: Required
Permissions: Only the author can access.
Description: Delete a specific subsection.
Response:
204 No Content
: If the subsection is successfully deleted.404 Not Found
: If the subsection with the specified ID does not exist.403 Forbidden
: If the user does not have permission.
Method: POST
Authentication: Required
Permissions: Only the author can add collaborators to a book.
Description: Add a collaborator to a book.
Response:
200 OK
: If the collaborator is successfully added.403 Forbidden
: If the user does not have permission.
Method: POST
Authentication: Required
Permissions: Only the author can remove collaborators from a book.
Description: Remove a collaborator from a book.
Response:
200 OK
: If the collaborator is successfully removed.403 Forbidden
: If the user does not have permission.