8000 Update to use Django-environ · graphql-python/swapi-graphene@8df8dfe · GitHub
[go: up one dir, main page]

Skip to content

Commit 8df8dfe

Browse files
committed
Update to use Django-environ
1 parent 21a3ba8 commit 8df8dfe

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

requirements_base.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ Django==1.9.2
22
graphene[django]==0.7.3
33
django-graphiql==0.4.4
44
django-filter==0.12.0
5+
django-environ==0.4.0

swapi_graphene/settings.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,29 +138,21 @@
138138
# Change the database setup if we have DB environment
139139
# vars. Useful for Heroku/Dokku databases
140140

141-
DB_NAME = os.environ.get('DB_NAME')
142-
DB_HOST = os.environ.get('DB_HOST')
143-
DB_USER = os.environ.get('DB_USER')
144-
DB_PASSWORD = os.environ.get('DB_PASS')
145-
DB_PORT = os.environ.get('DB_PORT')
141+
DATABASE_URL = os.environ.get('DATABASE_URL')
142+
143+
if DATABASE_URL:
144+
import environ
145+
env = environ.Env()
146146

147-
if DB_NAME and DB_HOST and DB_USER:
148147
DATABASES = {
149-
'default': {
150-
'ENGINE': 'django.db.backends.mysql',
151-
'NAME': DB_NAME,
152-
'HOST': DB_HOST,
153-
'USER': DB_USER,
154-
'PASSWORD': DB_PASSWORD,
155-
'PORT': DB_PORT,
148+
'default': dict({
156149
'OPTIONS': {
157-
'init_command': 'SET storage_engine=InnoDB',
158150
'charset': 'utf8',
159151
'use_unicode': True,
160152
},
161153
'TEST_CHARSET': 'utf8',
162154
'TEST_COLLATION': 'utf8_general_ci',
163-
}
155+
}, **env.db())
164156
}
165157

166158
GRAPHENE_SCHEMA = 'starwars.schema'

0 commit comments

Comments
 (0)
0