This guide provides steps to set up the project with Python version 3.10.13, including PostgreSQL installation and Django configuration.
- Python 3.10.13 installed on your system
-
Clone the Repository
git clone https://github.com/manavgoyal53/PO-CRUD-APP.git cd PO-CRUD-APP
-
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
-
-
Start PostgreSQL Service
Ensure PostgreSQL is running as a service after installation. On most systems, it starts automatically after installation.
-
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. -
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 andyour_password
with a strong password. -
Create a Database
Optionally, create a new database:
CREATE DATABASE your_database_name;
Replace
your_database_name
with the desired database name. -
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
andyour_username
with the respective names. -
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
-
-
Install Required Packages
pip install -r requirements.txt
-
Database Configuration
Update the
DATABASES
configuration insettings.py
with your PostgreSQL settings -
Apply Migrations
Run the following command to apply database migrations:
python manage.py migrate
-
Run the Server
Start the Django development server:
python manage.py runserver
Access the application at
http://127.0.0.1:8000/
-
Documentation
Use the following link to view the documentation:
http://127.0.0.1:8000/api/schema/swagger-ui/
- 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.