Skip to content

Commit 0931ce5

Browse files
committed
feat: connection using database link
1 parent e1d32d5 commit 0931ce5

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
web: cd backend && gunicorn website.wsgi
2-
release: cd backend && python manage.py makemigrations && python manage.py migrate
2+
release: cd backend && python manage.py makemigrations account && python manage.py makemigrations && python manage.py migrate

backend/account/authentication.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def authenticate(self, request):
2020
)
2121

2222
except jwt.ExpiredSignatureError:
23-
raise exceptions.AuthenticationFalied("Access token has expired!")
23+
raise exceptions.AuthenticationFailed("Access token has expired!")
2424

2525
except IndexError:
2626
raise exceptions.AuthenticationFalied("Token missing!")

backend/account/views.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def post(self, request):
2323

2424
uuid = serializer.validated_data["uuid"]
2525

26-
User.objects.get_or_create(uuid=uuid, role="admin")
26+
user, created = User.objects.get_or_create(uuid=uuid)
27+
user.role = "admin"
28+
user.save()
2729

2830
access_token = generate_access_token(uuid, "admin")
2931
refresh_token = generate_refresh_token(uuid, "admin")

backend/website/settings.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from decouple import config
1616
import django_heroku
1717

18+
import dj_database_url
19+
1820
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1921
BASE_DIR = Path(__file__).resolve().parent.parent
2022

@@ -85,16 +87,8 @@
8587
# Database
8688
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
8789

88-
DATABASES = {
89-
"default": {
90-
"ENGINE": "django.db.backends.postgresql_psycopg2",
91-
"NAME": "postgres",
92-
"USER": "postgres",
93-
"PASSWORD": config("DB_PASSWORD"),
94-
"HOST": "localhost",
95-
"PORT": "5432",
96-
}
97-
}
90+
DATABASES = {}
91+
DATABASES['default'] = dj_database_url.config(conn_max_age=600, ssl_require=True)
9892

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

0 commit comments

Comments
 (0)