add .env, wired database to settings, updated readme

This commit is contained in:
Sam
2021-01-21 10:29:35 +00:00
parent e1a92f2273
commit adb1371599
5 changed files with 51 additions and 23 deletions

3
.gitignore vendored
View File

@@ -6,6 +6,9 @@
# VSCode
.vscode/
# environment variables
.env
# Node artifact files
node_modules/
dist/

View File

@@ -1,29 +1,21 @@
# README #
# LaTiendaCOOP backend
This README would normally document whatever steps are necessary to get your application up and running.
This README aims to document functionality of backend as well as required steps to get it up and running.
### What is this repository for? ###
## Table of Contents
* Quick summary
* Version
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
- [First Steps](#first-steps)
### How do I get set up? ###
* Summary of set up
* Configuration
* Dependencies
* Database configuration
* How to run tests
* Deployment instructions
## First Steps
### Contribution guidelines ###
- Clone repository:
`git clone git@bitbucket.org:enreda/back-latienda.git`
- From inside the project's folder:
```
python manage.py makemigrations core companies products history stats
python migrate
* Writing tests
* Code review
* Other guidelines
```
### Who do I talk to? ###
* Repo owner or admin
* Other community or team contact

View File

@@ -12,9 +12,16 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
import os
import dotenv
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Get variables from .env
dotenv.read_dotenv(
dotenv=os.path.join(BASE_DIR, '.env'),
override=True
)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
@@ -37,6 +44,13 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'core',
'companies',
'products',
'history',
'stats',
]
MIDDLEWARE = [
@@ -73,11 +87,16 @@ WSGI_APPLICATION = 'back_latienda.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
# Databases configuration
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.getenv('DB_NAME'),
'USER': os.getenv('DB_USER'),
'PASSWORD': os.getenv('DB_PASSWORD'),
'HOST': os.getenv('DB_HOST', 'localhost'),
'PORT': os.getenv('DB_PORT', '5432'),
},
}

6
example.env Normal file
View File

@@ -0,0 +1,6 @@
# rename file to .env and populate fields accordingly
DB_HOST = 'localhost'
DB_PORT = '3306'
DB_NAME = ''
DB_USER = ''
DB_PASSWORD = ''

8
requirements.txt Normal file
View File

@@ -0,0 +1,8 @@
Django==2.2.17
djangorestframework==3.12.2
djangorestframework-simplejwt==4.4.0
factory-boy==3.1.0
django-dotenv==1.4.2
django-filter==2.4.0
-e git://github.com/darklow/django-suit/@v2#egg=django-suit
django-cors-headers==3.5.0