/PO-CRUD-APP

A basic crud app for creating purchase orders with supplier and line item details

Primary LanguagePython

Project Setup Guide

This guide provides steps to set up the project with Python version 3.10.13, including PostgreSQL installation and Django configuration.

Prerequisites

  • Python 3.10.13 installed on your system

Installation Steps

  1. Clone the Repository

    git clone https://github.com/manavgoyal53/PO-CRUD-APP.git
    cd PO-CRUD-APP
  2. Install PostgreSQL

    • For Windows: Download the installer from the official PostgreSQL website and follow the installation steps.

    • For macOS: You can use Homebrew to install PostgreSQL:

      brew install postgresql

      Follow the instructions in the terminal after installation.

    • For Linux: Use your distribution's package manager. For example, for Ubuntu:

      sudo apt-get update
      sudo apt-get install postgresql
  3. Start PostgreSQL Service

    Ensure PostgreSQL is running as a service after installation. On most systems, it starts automatically after installation.

  4. Access PostgreSQL Shell

    Open a terminal or command prompt and access the PostgreSQL shell using the psql command:

    sudo -u postgres psql

    Here, postgres is the default superuser created during PostgreSQL installation.

  5. Create a New User

    Inside the PostgreSQL shell, create a new user with a password and superuser privileges:

    CREATE USER your_username WITH PASSWORD 'your_password' SUPERUSER;

    Replace your_username with the desired username and your_password with a strong password.

  6. Create a Database

    Optionally, create a new database:

    CREATE DATABASE your_database_name;

    Replace your_database_name with the desired database name.

  7. Grant Privileges

    Grant privileges to the user on the database:

    GRANT ALL PRIVILEGES ON DATABASE your_database_name TO your_username;

    Replace your_database_name and your_username with the respective names.

  8. Create a Virtual Environment

    Create a virtual environment for the project:

    python3.10 -m venv env_name

    Activate the virtual environment:

    • On Windows:

      env_name\Scripts\activate
    • On macOS and Linux:

      source env_name/bin/activate
  9. Install Required Packages

    pip install -r requirements.txt
  10. Database Configuration

    Update the DATABASES configuration in settings.py with your PostgreSQL settings

  11. Apply Migrations

    Run the following command to apply database migrations:

    python manage.py migrate
  12. Run the Server

    Start the Django development server:

    python manage.py runserver

    Access the application at http://127.0.0.1:8000/

  13. Documentation

    Use the following link to view the documentation:

    http://127.0.0.1:8000/api/schema/swagger-ui/

Additional Notes

  • Ensure that PostgreSQL is running and accessible with the provided credentials.
  • For production setups, ensure to secure sensitive data like passwords using environment variables or configuration management tools.