GoRide is a web platform for bike and scooter rentals, developed as part of a semester project by a team of three students. The platform is built using Django and aims to provide an easy-to-use system for browsing, renting, and managing rides.
GoRide is designed to offer a simple and efficient platform for renting bikes and scooters. Users will be able to register, check availability, and make bookings, all through an intuitive interface. This project is being developed as part of a semester-long course.
This project is being developed by a team of three students as part of a semester project. The focus is on learning and applying Django to create a functional, real-world application.
This guide will help you and your team set up a Django project efficiently without using Docker. It includes environment setup, dependency management, code formatting, and workflow automation.
- Django Documentation
- pip-tools Documentation
- pre-commit Documentation
- Black (Code Formatter)
- Flake8 (Linter)
- Conventional Commits
- Python 3.x installed
- Git installed
git clone https://github.com/Cursyy/GoRide.git
cd projectpython -m venv env
source env/bin/activate # macOS/Linux
env\Scripts\activate # WindowsInstall all the necessary dependencies using pip:
pip install <package-name>After installing all the required packages, freeze the installed packages into a requirements.txt file:
pip freeze > requirements.txtCommit and push the requirements.txt to the repository.
Installing Dependencies from requirements.txt:
To install the dependencies on a new environment or for other team members, simply run:
pip install -r requirements.txt- Steps 1 and 2 are only necessary for the person who is setting up the project environment for the first time.
- Other team members who have already installed the dependencies can skip Steps 1 and 2 and directly move on to Step 3.
You can install invoke via pip:
pip install invokeInstead of using a justfile, you'll create a tasks.py file in your project root. This file will contain all the commands you'd like to automate.
from invoke import task
@task
def setup(ctx):
"""Set up the virtual environment and install dependencies."""
ctx.run("python -m venv env")
ctx.run("env/bin/activate && pip install -r requirements.txt")
ctx.run("invoke migrate")
ctx.run("invoke run")
@task
def run(ctx):
"""Run the Django development server."""
ctx.run("python manage.py runserver")
@task
def migrate(ctx):
"""Apply database migrations."""
ctx.run("python manage.py migrate")
@task
def createsuperuser(ctx):
"""Create a superuser for the Django project."""
ctx.run("python manage.py createsuperuser")Once you have the tasks.py file set up, you can run the tasks using invoke:
invoke setupThis will automatically set up the project, activate the virtual environment, install dependencies, and run any other tasks you define in the tasks.py.
We use pre-commit to enforce coding standards:
pip install pre-commit
pre-commit installAdd .pre-commit-config.yaml:
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8Now, before each commit, code will be automatically formatted.
mainβ Stable production-ready branchdevelopβ Active development branchfeature/*β Feature branches
Example workflow:
git checkout -b feature/auth
# Make changes
git commit -m "Added authentication"
git push origin feature/authWe follow Conventional Commits to maintain a clear commit history.
- Helps automate changelogs
- Improves collaboration and readability
- Standardizes commit messages
type(scope): short description
git commit -m "feat(auth): add login functionality"
git commit -m "fix(api): resolve 500 error on GET request"
git commit -m "docs(readme): update setup instructions"feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (no logic changes)refactor: Code refactoring (no new features or fixes)test: Adding or updating testschore: Maintenance tasks (e.g., dependencies, CI/CD updates)
Daphne is an asynchronous HTTP, WebSocket, and HTTP/2 server for Django, used with Channels for handling WebSockets and async requests.
- WebSockets: For real-time communication (e.g., chat, notifications).
- Async Requests: To handle high-performance async operations.
- Scaling: Supports high-load, asynchronous connections.
- Run Daphne:
daphne your_project.asgi:application - Run Daphne on a specific port:
daphne -p 8001 your_project.asgi:application - Run Daphne on all interfaces:
daphne -b 0.0.0.0 -p 8001 your_project.asgi:application - Check Daphne version:
daphne --version
- Install Docker (https://www.docker.com/)
docker-compose build
docker-compose up
This command will create all necessary containers (Django, Redis, PostgreSQL, etc.) and start them.
docker-compose up --build
This command applies database migrations in the container.
docker-compose exec web python manage.py migrate
Use this command to create a superuser for accessing the Django admin panel.
docker-compose exec web python manage.py createsuperuser
This command collects all static files (CSS, JavaScript, images) for serving through Nginx.
docker-compose exec web python manage.py collectstatic --noinput
This command starts the Celery process for background task processing.
docker-compose exec celery celery -A GoRide.celery worker --loglevel=info
This command starts Celery Beat for task scheduling.
docker-compose exec celery-beat celery -A GoRide.celery beat --loglevel=info
Run tests in the container to verify the functionality of the project.
docker-compose exec web python manage.py test
This command allows you to view container logs for debugging or monitoring.
docker-compose logs web
This command restarts all services in containers after code changes.
docker-compose restart