Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config environ #23

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ djangorestframework==3.9.2
# Packages needed for running the tests. Needed by contributors.
# ==============================================================
factory-boy==2.11.1
python-environ==0.4.54
18 changes: 8 additions & 10 deletions tinylinks/management/commands/_config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
user = ""
password = ""
host = "127.0.0.1"
database = ""
raise_on_warnings = True
import environ
env = environ.Env()
env.read_env(".env")

config = {
"user": user,
"password": password,
"host": host,
"database": database,
"raise_on_warnings": raise_on_warnings,
"user": env.str("MYSQL_USER", ""),
"password": env.str("MYSQL_PASSWORD", ""),
"host": env.str("MYSQL_HOSTNAME", ""),
"database": env.str("MYSQL_DATABASE", ""),
"raise_on_warnings": env.bool("MYSQL_RAISE_ON_WARNING", ""),
}


Expand Down
2 changes: 1 addition & 1 deletion tinylinks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def create(self, request, *args, **kwargs):
headers = self.get_success_headers(serializer.data)
data = {
"id": instance.id,
"short_url": request.build_absolute_uri("/%s" % instance.short_url),
"short_url": request.build_absolute_uri("/%s" % instance.get_short_url()),
"long_url": instance.long_url,
}

Expand Down