Skip to content

Commit

Permalink
Adicionado variaveis de ambiente
Browse files Browse the repository at this point in the history
  • Loading branch information
feliperian committed Dec 23, 2019
1 parent 080843a commit 4757c41
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,33 @@
Sistema Loja com controle de montagem de computadores pelo cliente.

# Iniciando
Crie um usuario para gerenciar o sistema através do comando
### Instale as dependencias
```
pip install -r requirements.txt
```

### Definir as seguintes variáveis no ambiente
```
SECRET_KEY # Chave de criptografia do django
DEBUG # Aplicacao iniciará em modo de debug ("True", "False")
DATABASE_URL # URL de acesso ao banco de dados
```

### Prepare o banco para a aplicação
```
python manage.py migrate
```

### Crie um usuário para gerenciar o sistema através do comando
```
python manage.py createsuperuser
```

### Iniciando a aplicação
```
python manage.py runserver
```

# Administração
O cadastro de usuários e produtos é feito pela administração.
Também é possível cadastrar uma montagem pela administração.
Expand Down
14 changes: 7 additions & 7 deletions loja/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

import os
import dj_database_url

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand All @@ -20,14 +21,14 @@
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'hmsojh!z5r33&5-g0(g=5f$2im(#+rx45g$f=$6zv&dm70nv)b'
SECRET_KEY = os.environ.get(
'SECRET_KEY', 'hmsojh!z5r33&5-g0(g=5f$2im(#+rx45g$f=$6zv&dm70nv)b')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = os.environ.get('DEBUG', "True") in ["True", "true"]

ALLOWED_HOSTS = ['*']


# Application definition

INSTALLED_APPS = [
Expand Down Expand Up @@ -77,10 +78,9 @@
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
'default': dj_database_url.config(
default=os.environ.get('DATABASE_URL', 'sqlite:///db.sqlite3')
)
}


Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
dj-database-url==0.5.0
Django==3.0.1
django-filter==2.2.0
djangorestframework==3.11.0
gunicorn==20.0.4
psycopg2-binary==2.8.4
whitenoise==4.0
psycopg2-binary==2.8.4

0 comments on commit 4757c41

Please sign in to comment.