- Create a new repository using this repo as a template
- Create and Activate the virtual env
python -m venv env && source env/bin/activate
- Install the development dependencies
pip install -r requirements/dev.txt
- Configure Pre-commit (Optional)
pre-commit install && pre-commit run --all-files
-
Setup
localhost
as the db host insettings.py
-
Cd into
api
folder
cd api
- Apply the migrations
python manage.py migrate
- Run the development server
python manage.py runserver
- Navigate to http://localhost:8000 to view the
OpenAPI
swagger docs - Happy hacking!
To set up PostgreSQL on a Linux system, you will need to do the following steps:
Install the PostgreSQL package:
sudo apt-get install postgresql postgresql-contrib
Start the PostgreSQL service:
sudo service postgresql start
Log in to the PostgreSQL command-line interface as the postgres user:
sudo -u postgres psql
Create a new database and user:
CREATE DATABASE mydatabase;
CREATE USER myuser WITH PASSWORD 'mypassword';
GRANT ALL PRIVILEGES ON DATABASE mydatabase TO myuser;
Note: Dont use the username
user
as it will conflict with the command
Exit the PostgreSQL command-line interface:
\q
Update the Django settings to use the new database:
# settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'mydatabase',
'USER': 'myuser',
'PASSWORD': 'mypassword',
'HOST': 'localhost',
'PORT': '5432',
}
}
By following these steps, you should be able to set up PostgreSQL on your Linux system and use it with Django.