From 0d38bf62330e2fcc27e83dfa3b8ff3b6fd6e15a0 Mon Sep 17 00:00:00 2001 From: Andrew4Coding Date: Thu, 10 Oct 2024 15:16:41 +0700 Subject: [PATCH] feat: add vercel json --- eventyog/settings.py | 46 ++++++++++++---------- main/views.py | 2 +- static/{css/global.css => styles/main.css} | 0 templates/base.html | 8 ++-- vercel.json | 15 +++++++ 5 files changed, 45 insertions(+), 26 deletions(-) rename static/{css/global.css => styles/main.css} (100%) create mode 100644 vercel.json diff --git a/eventyog/settings.py b/eventyog/settings.py index 6ba256e..17c450d 100644 --- a/eventyog/settings.py +++ b/eventyog/settings.py @@ -1,31 +1,35 @@ """ Django settings for eventyog project. -Generated by 'django-admin startproject' using Django 4.2.16. +Generated by 'django-admin startproject' using Django 5.1. For more information on this file, see -https://docs.djangoproject.com/en/4.2/topics/settings/ +https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/4.2/ref/settings/ +https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path +import os # 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.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-@&$oww)3kym4#4ex8tz^+ky$h%gi$ev5if&=d+zkt=%(*-7!8r' +SECRET_KEY = 'django-insecure-zob1=r7z=fjniwac*ljo#^o*uiv201#xke*1#4+=m7xxdjx$pv' + +PRODUCTION = os.getenv('PRODUCTION', False) # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = not PRODUCTION + +ALLOWED_HOSTS = ['*'] -ALLOWED_HOSTS = ["*"] # Application definition @@ -41,8 +45,8 @@ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', @@ -72,7 +76,7 @@ # Database -# https://docs.djangoproject.com/en/4.2/ref/settings/#databases +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases DATABASES = { 'default': { @@ -83,7 +87,7 @@ # Password validation -# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -102,7 +106,7 @@ # Internationalization -# https://docs.djangoproject.com/en/4.2/topics/i18n/ +# https://docs.djangoproject.com/en/5.1/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -113,17 +117,17 @@ USE_TZ = True -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/4.2/howto/static-files/ - -STATIC_URL = '/static/' -STATICFILES_DIRS = [BASE_DIR / 'static'] - # Default primary key field type -# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -STATIC_ROOT = BASE_DIR / 'staticfiles' - -STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" \ No newline at end of file +# Static files (CSS, JavaScript, Images) +# Dokumentasi: https://docs.djangoproject .com/en/5.1/howto/static-files/ +STATIC_URL = '/static/' +if DEBUG: + STATICFILES_DIRS = [ + BASE_DIR / 'static' # merujuk ke /static root project pada mode development + ] +else: + STATIC_ROOT = BASE_DIR / 'static' \ No newline at end of file diff --git a/main/views.py b/main/views.py index a7d4e19..644f549 100644 --- a/main/views.py +++ b/main/views.py @@ -2,4 +2,4 @@ # Create your views here. def main(request): - return HttpResponse("Hello, World!") \ No newline at end of file + return render(request, 'base.html') \ No newline at end of file diff --git a/static/css/global.css b/static/styles/main.css similarity index 100% rename from static/css/global.css rename to static/styles/main.css diff --git a/templates/base.html b/templates/base.html index a598f70..b14794e 100644 --- a/templates/base.html +++ b/templates/base.html @@ -9,8 +9,7 @@ - {% comment %} {% endcomment %} - + - + + {% block meta %}{% endblock meta %} - +
{% block content %}{% endblock content%}
diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..b40a4bf --- /dev/null +++ b/vercel.json @@ -0,0 +1,15 @@ +{ + "builds": [ + { + "src": "eventyog/wsgi.py", + "use": "@vercel/python", + "config": { "maxLambdaSize": "15mb", "runtime": "python3.11.3" } + } + ], + "routes": [ + { + "src": "/(.*)", + "dest": "eventyog/wsgi.py" + } + ] +}