Skip to content

Commit

Permalink
Switched database
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel81 committed May 14, 2024
1 parent d2384d9 commit 4fc332e
Showing 1 changed file with 39 additions and 19 deletions.
58 changes: 39 additions & 19 deletions backend/Blizzr/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@

import os
from pathlib import Path
import cloudinary
import cloudinary.api
import cloudinary.uploader
import dj_database_url
from datetime import timedelta
from dotenv import load_dotenv

load_dotenv()

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
load_dotenv()
Expand All @@ -23,13 +30,13 @@
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-jomg4&dj&fet1o2$rxm9ut9v@&vp*@y7-1@2!$qd!(!fk#44-&"
SECRET_KEY = "django-insecure-jomg4&dj&fet1o2$rxm9ut9v@&vp*@y7-1@2!$qd!(!fk#44-&j"


# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ["*"]
ALLOWED_HOSTS = ["blizzrshop.onrender.com"]


# Application definition
Expand All @@ -42,17 +49,17 @@
'django.contrib.messages',
'django.contrib.staticfiles',

'store',
'accounts',
'corsheaders',
'cloudinary',
'accounts',
'store'
]

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
),
}
from datetime import timedelta
# JWT_AUTH = {
# 'JWT_EXPIRATION_DELTA': timedelta(seconds=300),
# }
Expand Down Expand Up @@ -80,7 +87,7 @@
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'staticfiles/')
os.path.join(BASE_DIR, 'frontend', 'dist')
],
'APP_DIRS': True,
'OPTIONS': {
Expand All @@ -96,16 +103,29 @@

WSGI_APPLICATION = 'Blizzr.wsgi.application'

cloudinary.config(
cloud_name=os.getenv('CLOUDINARY_NAME'),
api_key=os.getenv('CLOUDINARY_API_KEY'),
api_secret=os.getenv('CLOUDINARY_API_SECRET_KEY'),
)

CLOUDINARY_STORAGE = {
'CLOUD_NAME': os.getenv('CLOUDINARY_NAME'),
'API_KEY': os.getenv('CLOUDINARY_API_KEY'),
'API_SECRET': os.getenv('CLOUDINARY_API_SECRET_KEY'),
}


# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
# }
# }


# DATABASES = {
# 'default': {
Expand All @@ -118,13 +138,11 @@
# }
# }

# import dj_database_url

# database_url = os.getenv('DATABASE_URL')
import dj_database_url

# DATABASES = {
# 'default': dj_database_url.parse(database_url)
# }
DATABASES = {
'default': dj_database_url.config(default=os.getenv('DATABASE_URL'))
}


# Password validation
Expand Down Expand Up @@ -172,11 +190,13 @@
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'

DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'

STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
# STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'

# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

AUTH_USER_MODEL = 'accounts.User'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

0 comments on commit 4fc332e

Please sign in to comment.