Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README.md file for for voting platform project

Django Project Setup

This is a Django project using PostgreSQL as the database.

Requirements

  • Python 3.x
  • Django 3.x
  • PostgreSQL

Installation

  1. Clone the repository:

    git clone https://github.com/Bobybuu/KW_Awards-voting-platfom.git
    cd KW_Awards-voting-platfom/backend
  2. Create a virtual environment:

    python --version 
    python3 -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install dependencies:

    pip install -r requirements.txt
  4. Set up PostgreSQL:

Install PostgreSQL

On Windows

  • 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).

On macOS

  1. Install Homebrew

  2. Update Homebrew:

    brew update
  3. Install PostgreSQL:

    brew install postgresql
  4. Start PostgreSQL:

    brew services start postgresql

On Linux

  1. Update the package list:

    sudo apt update
  2. Install PostgreSQL and its contrib package:

    sudo apt install postgresql postgresql-contrib
  3. Start PostgreSQL:

    sudo systemctl start postgresql
  4. Enable PostgreSQL to start on boot:

    sudo systemctl enable postgresql

Create a Database and a User for the Project

  1. Switch to the PostgreSQL user:

    sudo -i -u postgres
  2. Access the PostgreSQL prompt:

    psql
  3. 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
  4. Exit the PostgreSQL prompt:

    \q
  5. 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'),
        }
    }
  6. Apply migrations:

    python manage.py migrate
  7. Create a superuser:

    python manage.py createsuperuser
  8. Run the development server:

    python manage.py runserver

Usage

  • Access the admin site at http://127.0.0.1:8000/admin/

Working with Git Branches

  1. Create a new branch:

    git checkout -b your-branch-name
    git branch --set-upstream-to=origin/main <branch-name>  # If tracking main
  2. update from main after branch checkout

    git pull origin main
    
  3. Make your changes and commit them:

    git add .
    git commit -m "Your commit message"
  4. Push your branch to the remote repository:

    git push origin your-branch-name
  5. Create a pull request:

    Go to the repository on GitHub and create a pull request from your branch.

  6. Merge the pull request:

    Once your pull request is reviewed and approved, it can be merged into the main branch.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages