This is a Django project using PostgreSQL as the database.
- Python 3.x
- Django 3.x
- PostgreSQL
-
Clone the repository:
git clone https://github.com/Bobybuu/KW_Awards-voting-platfom.git cd KW_Awards-voting-platfom/backend -
Create a virtual environment:
python --version python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Set up PostgreSQL:
- Download the installer from the PostgreSQL Downloads page.
- Run the installer and follow the setup wizard.
- Set a password for the PostgreSQL superuser (default user is
postgres). - Choose the port number (default is 5432).
-
Install Homebrew
-
Update Homebrew:
brew update
-
Install PostgreSQL:
brew install postgresql
-
Start PostgreSQL:
brew services start postgresql
-
Update the package list:
sudo apt update
-
Install PostgreSQL and its contrib package:
sudo apt install postgresql postgresql-contrib
-
Start PostgreSQL:
sudo systemctl start postgresql
-
Enable PostgreSQL to start on boot:
sudo systemctl enable postgresql
-
Switch to the PostgreSQL user:
sudo -i -u postgres
-
Access the PostgreSQL prompt:
psql
-
Create a database and a user for the project:
CREATE DATABASE yourdbname; -- Create the database CREATE USER yourdbuser WITH PASSWORD 'yourpassword'; -- Create the user ALTER ROLE yourdbuser SET client_encoding TO 'utf8'; -- Set the encoding ALTER ROLE yourdbuser SET default_transaction_isolation TO 'read committed'; -- Set the transaction isolation level ALTER ROLE yourdbuser SET timezone TO 'UTC'; -- Set the timezone GRANT ALL PRIVILEGES ON DATABASE yourdbname TO yourdbuser; -- Grant privileges to the user on the database \l -- List all your databases \c yourdbname -- Connect to your database CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; -- Create the uuid-ossp extension \du -- List all your users and their privileges
-
Exit the PostgreSQL prompt:
\q
-
Configure the database in :
Edit your file to include the following:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': os.getenv('DB_NAME'), 'USER': os.getenv('DB_USER'), 'PASSWORD': os.getenv('DB_PASSWORD'), 'HOST': os.getenv('DB_HOST'), 'PORT': os.getenv('DB_PORT'), } }
-
Apply migrations:
python manage.py migrate
-
Create a superuser:
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
- Access the admin site at
http://127.0.0.1:8000/admin/
-
Create a new branch:
git checkout -b your-branch-name
git branch --set-upstream-to=origin/main <branch-name> # If tracking main
-
update from main after branch checkout
git pull origin main
-
Make your changes and commit them:
git add . git commit -m "Your commit message"
-
Push your branch to the remote repository:
git push origin your-branch-name
-
Create a pull request:
Go to the repository on GitHub and create a pull request from your branch.
-
Merge the pull request:
Once your pull request is reviewed and approved, it can be merged into the main branch.