This project is a backend system for a group messaging and file-sharing application. It allows users to register, create groups, send messages (both individual and group messages), and share files within groups. The project is built using Django and Django REST framework (DRF).
- User Registration and Authentication
- Group Creation
- Sending Individual Messages
- Sending Group Messages
- Uploading and Sharing Files within Groups
- Listing Group Messages and Files
- Django
- Django REST Framework (DRF)
- SQLite (default database)
- Postman (for API testing)
- Python 3.x
- pip (Python package installer)
-
Clone the repository:
git clone https://github.com/Arkutu/DjangoTests.git cd DjangoTests -
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install dependencies:
pip install -r requirements.txt
-
Apply migrations:
python manage.py makemigrations python manage.py migrate
-
Create a superuser (for accessing the admin panel):
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
- URL:
/api/register/ - Method:
POST - Request Body:
{ "username": "testuser", "email": "testuser@example.com", "password": "testpassword" } - Response: Details of the created user.
- URL:
/api/login/ - Method:
POST - Request Body:
{ "username": "testuser", "password": "testpassword" } - Response: Token, user ID, and email.
- URL:
/api/create_group/ - Method:
POST - Headers:
Authorization: Token <your-token>
- Request Body:
{ "name": "testgroup", "members": [1, 2, 3] // Add user IDs } - Response: Details of the created group.
- URL:
/api/send_group_message/ - Method:
POST - Headers:
Authorization: Token <your-token>
- Request Body:
{ "group": 1, // Group ID "message": "Hello Group!" } - Response: Message details.
- URL:
/api/group_messages/<group_id>/ - Method:
GET - Headers:
Authorization: Token <your-token>
- Response: List of messages in the group.
- URL:
/api/send_message/ - Method:
POST - Headers:
Authorization: Token <your-token>
- Request Body:
{ "receiver": 2, // Receiver User ID "message": "Hello!" } - Response: Message details.
- URL:
/api/messages/ - Method:
GET - Headers:
Authorization: Token <your-token>
- Response: List of individual messages.
- URL:
/api/upload_file/ - Method:
POST - Headers:
Authorization: Token <your-token>
- Request Body (form-data):
uploader(Text): Uploader User IDgroup(Text): Group IDfile(File): File to upload
- Response: File details.
- URL:
/api/group_files/<group_id>/ - Method:
GET - Headers:
Authorization: Token <your-token>
- Response: List of files in the group.
- Open Postman and create a new request.
- Set the request type (GET, POST, etc.) and the URL for the endpoint.
- Add headers if required (e.g.,
Authorizationtoken). - Set the request body for POST requests (use
rawandJSONformat for JSON bodies). - Send the request and check the response.
Contributions are welcome! Please open an issue or submit a pull request for any changes or improvements.