Skip to content

Commit

Permalink
update settings for azure deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
molin6 committed Feb 27, 2024
1 parent 6223667 commit 892f93e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 41 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ python-dotenv==1.0.1
sqlparse==0.4.4
typing-extensions==4.10.0
tzdata==2024.1
dj-database-url
47 changes: 6 additions & 41 deletions restaurantweb/settings.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
"""
Django settings for restaurantweb project.
Generated by 'django-admin startproject' using Django 4.1.3.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""

from pathlib import Path
import os
from dotenv import load_dotenv

import dj_database_url # Import dj_database_url

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('SECRET_KEY')

Expand All @@ -30,7 +13,6 @@

ALLOWED_HOSTS = ['*']


# Application definition

INSTALLED_APPS = [
Expand Down Expand Up @@ -65,34 +47,17 @@
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages'
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'restaurantweb.wsgi.application'


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

# Load environment variables from .env file
load_dotenv()

BASE_DIR = Path(__file__).resolve().parent.parent

# ...

# Database configuration using dj-database-url
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv('DATABASE_NAME'),
'USER': os.getenv('DATABASE_USER'),
'PASSWORD': os.getenv('DATABASE_PASSWORD'),
'HOST': os.getenv('DATABASE_HOST'),
'PORT': os.getenv('DATABASE_PORT', '5432'), # Default PostgreSQL port
}
'default': dj_database_url.config(default=os.getenv('AZURE_POSTGRESQL_CONNECTIONSTRING'))
}

# Password validation
Expand All @@ -113,7 +78,6 @@
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/

Expand All @@ -123,8 +87,9 @@

USE_I18N = True

USE_TZ = True
USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
Expand Down

0 comments on commit 892f93e

Please sign in to comment.