https://github.com/adia-dev/backend-jimmy
https://github.com/adia-dev/backend-jimmy
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/adia-dev/backend-jimmy
- Owner: adia-dev
- Created: 2024-03-03T21:10:42.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-04T09:33:30.000Z (about 2 years ago)
- Last Synced: 2025-02-18T06:47:06.508Z (about 1 year ago)
- Language: Python
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Example python project
This is a demo project for django with a rest API using a postgresql database.
## Requirements
Here are the tools you need to run this project :
- Python
- Docker + Docker compose
## Setup
### Create a virtual environment
```sh
python -m venv venv
```
### Activate the virtual environment
```sh
.\venv\Scripts\activate # Windows powershell
source ./venv/bin/activate # Linux and Mac
```
### Install dependencies
```sh
pip install -r ./requirements/dev.txt
```
## Load environment variables
This project requires environment variables to be configured in order to run. The list is avaialable at the end of this
document. You can also see a list of variables in the .env.example file.
There are multiple ways to load variables in your terminal depending on your OS, so feel free to do it however you please.
## Run the database
While working in a local environment, you can use the compose file provided to run a database.
```shell
docker compose up -d
```
## Run migrations
Migrations will apply the necessary scripts to setup your database and apply changes made in your models.
```shell
python ./manage.py migrate
```
## Load initial data
```shell
python ./manage.py loaddata ./fixtures/articles.json
```
## Run a local development server
```shell
python ./manage.py runserver
```
## Run the server in production mode
You can use the provided script `start.sh` to run a production instance. It will wait for the database to be ready,
apply migrations and then load inital data. This script should be ran inside a Dockerfile.
## List of available environment variables
- `DATABASE_HOST`: The hostname to access your database
- `DATABASE_PORT`: The port to access your database
- `DATABASE_USER`: The username to access your database
- `DATABASE_PASSWORD`: The password to access your database
- `DATABASE_NAME`: The name of the database