Skip to content

Commit

Permalink
Merge pull request #12 from gustavodsantos/01
Browse files Browse the repository at this point in the history
branch 01 testando postgres
  • Loading branch information
gustavodsantos authored Mar 15, 2024
2 parents faf5967 + c7ab4c1 commit 210e9e7
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 61 deletions.
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ name = "pypi"
django = "*"
gunicorn = "*"
python-decouple = "*"
dj-database-url = "*"
psycopg2-binary = "*"

[dev-packages]
flake8 = "*"
Expand Down
203 changes: 149 additions & 54 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion contrib/env-sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DEBUG=False
SECRET_KEY=defina sua chave secreta
ALLOWED_HOSTS=localhost,127.0.0.1
ALLOWED_HOSTS=localhost,127.0.0.1
DATABASE_URL=postgres://postgres:postgres@localhost/postgres
16 changes: 10 additions & 6 deletions pypro/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
"""

# import os
import os.path
from functools import partial
from pathlib import Path

import dj_database_url
from decouple import config, Csv

# Build paths inside the project like this: BASE_DIR / 'subdir'.
Expand Down Expand Up @@ -75,14 +79,14 @@
# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases

default_db_url = 'sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3')

parse_database = partial(dj_database_url.parse, conn_max_age=600)

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
'default': config('DATABASE_URL', default=default_db_url, cast=parse_database)
}


# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators

Expand Down

0 comments on commit 210e9e7

Please sign in to comment.