Note : The Security Key in the Settings.py file is not provided in the code for security Reasons , Please make a new project and copy all the contents or email me for security key
Assumes you have python3...
- Fork the repo on github to get a copy of the respository, and then cloned that newly forked repo with
git clone
- Create a virtual environment with the
python -m venv .venv
.This will a sandboxed environment called "venv" that helps with controlling dependencies. - Activate the environment with
source .venv/bin/activate
- Install all the application's dependencies (while in the activated virtual environment) with
pip install -r requirements.txt
.
Since we want to use postgres as our production database, we should make sure that any local development is also done with postgres. Setting postgres up to run on a machine locally is more of a hassle than the default 'db.sqlite3' database that django, but using it locally ensures that no weird errors crop up by having different database implementations across environments development and production environments.
- Install homebrew if it's not already on your Mac.
- Update brew with
brew update
. - Install postgres with
brew install postgres
. - To start postgres consistently run in the background, use the command
brew services start postgresql
. If you'd prefer to start it manually and not have it automatically start usepg_ctl -D /usr/local/var/postgres start
. - Make sure that everything is working properly by entering postgres's command line interface with
psql postgres
. You should see you enter a shell that looks likepostgres=#
. - Once in the interface, create a new database named djangotutorial with the command
CREATE DATABASE djangotutorial;
If creating the database succeeds, you will see the responseCREATE DATABASE
. This will be the database that our django application will connect and write to for local development. - For anyone to connect and access the database we created, they need a valid postgres username and password combination. This means that we need to create a dedicated user for django to interact with our new database. We create it with
CREATE USER djangotutorial WITH PASSWORD 'supersecret';
- Our new postgres user needs explicit permission to have read and write capabilities on our newly created database. We can do that with the command
GRANT ALL PRIVILEGES ON DATABASE "djangotutorial" to djangotutorial;
. - Exit out of postgres
- Make sure you have your postgres username and Database name before doing this step
- Go the settings.py in the main app (tata) and modify the database values according to your configration
- Make migrations using
Python3 manage.py makemigrations
- Then use the migrate command
Python3 manage.py migrate
- Run the Server to see Everything went right
python3 manage.py runserver