This project is a simple social network built with Django and Django Rest Framework. It includes user registration, login, and a basic friend request system.
- User registration and authentication
- Sending and accepting friend requests
- Viewing pending and sent friend requests
- Paginated user search
-
Register
- Endpoint:
users/register/
- Description: Register a new user.
- Required Data:
password
,email
. - optional Data:
first_name
,last_name
. - Returns:
- Success:
token
(Authentication token for the registered user). - Error:
error
message for invalid or incomplete data.
- Success:
- Endpoint:
-
Login
- Endpoint:
users/login/
- Description: Log in an existing user.
- Required Data:
email
,password
. - Returns:
- Success:
token
(Authentication token for the logged-in user). - Error:
error: 'Invalid credentials'
for incorrect login credentials.
- Success:
- Endpoint:
-
User Details
- Endpoint:
users/user/
- Description: Retrieve details of the authenticated user.
- Required Data: None (Authentication token is required).
- Returns:
- Details of the authenticated user.
- Endpoint:
-
Search Users
- Endpoint:
users/search/
- Description: Search for users by email or username.
- Required Data:
keyword
(Search keyword for email or username). - Returns:
- List of users matching the search criteria.
- Endpoint:
-
Send Friend Request
- Endpoint:
connections/send_friend_request/
- Description: Send a friend request from the authenticated user to another user.
- Required Data:
to_user_id
(ID of the user to whom the friend request is sent). - Returns:
- Success:
message: 'Friend request sent successfully.'
- Error:
error: 'You cannot send a friend request to yourself.'
,error: 'Friend request already sent.'
, or other relevant error messages.
- Success:
- Endpoint:
-
Accept Friend Request
- Endpoint:
connections/accept_friend_request/
- Description: Accept a friend request sent to the authenticated user.
- Required Data:
from_user_id
(ID of the user who sent the friend request). - Returns:
- Success:
message: 'Friend request accepted successfully.'
- Error:
error: 'Friend request already accepted.'
, or other relevant error messages.
- Success:
- Endpoint:
-
Reject Friend Request
- Endpoint:
connections/reject_friend_request/
- Description: Reject a friend request sent to the authenticated user.
- Required Data:
from_user_id
(ID of the user who sent the friend request). - Returns:
- Success:
message: 'Friend request rejected successfully.'
- Error:
error: 'Friend request already accepted.'
, or other relevant error messages.
- Success:
- Endpoint:
-
Check Pending Requests
- Endpoint:
connections/pending_requests/
- Description: Retrieve pending friend requests sent to the authenticated user.
- Required Data: None (Authentication token is required).
- Returns:
- List of pending friend requests.
- Endpoint:
-
Check Sent Requests
- Endpoint:
connections/sent_requests/
- Description: Retrieve sent friend requests by the authenticated user.
- Required Data: None (Authentication token is required).
- Returns:
- List of sent friend requests.
- Endpoint:
-
Check Friends
- Endpoint:
connections/check_friends/
- Description: Retrieve friends of the authenticated user.
- Required Data: None (Authentication token is required).
- Returns:
- List of friends.
git clone https://github.com/rudra-g/social_network_backend_django.git
cd my-django-project
docker-compose build
docker-compose up
docker-compose down
git clone https://github.com/rudra-g/social_network_backend_django.git
cd my-django-project
python -m venv env
source env/bin/activate # On Windows use `env\Scripts\activate`
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
python manage.py test
License This project is licensed under the MIT License. See the LICENSE file for details.