From db05a5824e92c98e18898871863cb766e1007092 Mon Sep 17 00:00:00 2001 From: Amusat Haki Adeyemi Date: Mon, 1 May 2023 17:46:18 +0100 Subject: [PATCH 1/2] directory rearangent for django standard --- sherlock_rest_service/manage.py => manage.py | 0 {sherlock_rest_service/sherlock_api => sherlock_api}/__init__.py | 0 {sherlock_rest_service/sherlock_api => sherlock_api}/admin.py | 0 {sherlock_rest_service/sherlock_api => sherlock_api}/apps.py | 0 .../sherlock_api => sherlock_api}/migrations/__init__.py | 0 {sherlock_rest_service/sherlock_api => sherlock_api}/models.py | 0 {sherlock_rest_service/sherlock_api => sherlock_api}/tests.py | 0 {sherlock_rest_service/sherlock_api => sherlock_api}/urls.py | 0 {sherlock_rest_service/sherlock_api => sherlock_api}/views.py | 0 sherlock_rest_service/{sherlock_rest_service => }/__init__.py | 0 sherlock_rest_service/{sherlock_rest_service => }/asgi.py | 0 sherlock_rest_service/{sherlock_rest_service => }/settings.py | 0 sherlock_rest_service/sherlock | 1 - sherlock_rest_service/{sherlock_rest_service => }/urls.py | 0 sherlock_rest_service/{sherlock_rest_service => }/wsgi.py | 0 15 files changed, 1 deletion(-) rename sherlock_rest_service/manage.py => manage.py (100%) mode change 100755 => 100644 rename {sherlock_rest_service/sherlock_api => sherlock_api}/__init__.py (100%) rename {sherlock_rest_service/sherlock_api => sherlock_api}/admin.py (100%) rename {sherlock_rest_service/sherlock_api => sherlock_api}/apps.py (100%) rename {sherlock_rest_service/sherlock_api => sherlock_api}/migrations/__init__.py (100%) rename {sherlock_rest_service/sherlock_api => sherlock_api}/models.py (100%) rename {sherlock_rest_service/sherlock_api => sherlock_api}/tests.py (100%) rename {sherlock_rest_service/sherlock_api => sherlock_api}/urls.py (100%) rename {sherlock_rest_service/sherlock_api => sherlock_api}/views.py (100%) rename sherlock_rest_service/{sherlock_rest_service => }/__init__.py (100%) rename sherlock_rest_service/{sherlock_rest_service => }/asgi.py (100%) rename sherlock_rest_service/{sherlock_rest_service => }/settings.py (100%) delete mode 120000 sherlock_rest_service/sherlock rename sherlock_rest_service/{sherlock_rest_service => }/urls.py (100%) rename sherlock_rest_service/{sherlock_rest_service => }/wsgi.py (100%) diff --git a/sherlock_rest_service/manage.py b/manage.py old mode 100755 new mode 100644 similarity index 100% rename from sherlock_rest_service/manage.py rename to manage.py diff --git a/sherlock_rest_service/sherlock_api/__init__.py b/sherlock_api/__init__.py similarity index 100% rename from sherlock_rest_service/sherlock_api/__init__.py rename to sherlock_api/__init__.py diff --git a/sherlock_rest_service/sherlock_api/admin.py b/sherlock_api/admin.py similarity index 100% rename from sherlock_rest_service/sherlock_api/admin.py rename to sherlock_api/admin.py diff --git a/sherlock_rest_service/sherlock_api/apps.py b/sherlock_api/apps.py similarity index 100% rename from sherlock_rest_service/sherlock_api/apps.py rename to sherlock_api/apps.py diff --git a/sherlock_rest_service/sherlock_api/migrations/__init__.py b/sherlock_api/migrations/__init__.py similarity index 100% rename from sherlock_rest_service/sherlock_api/migrations/__init__.py rename to sherlock_api/migrations/__init__.py diff --git a/sherlock_rest_service/sherlock_api/models.py b/sherlock_api/models.py similarity index 100% rename from sherlock_rest_service/sherlock_api/models.py rename to sherlock_api/models.py diff --git a/sherlock_rest_service/sherlock_api/tests.py b/sherlock_api/tests.py similarity index 100% rename from sherlock_rest_service/sherlock_api/tests.py rename to sherlock_api/tests.py diff --git a/sherlock_rest_service/sherlock_api/urls.py b/sherlock_api/urls.py similarity index 100% rename from sherlock_rest_service/sherlock_api/urls.py rename to sherlock_api/urls.py diff --git a/sherlock_rest_service/sherlock_api/views.py b/sherlock_api/views.py similarity index 100% rename from sherlock_rest_service/sherlock_api/views.py rename to sherlock_api/views.py diff --git a/sherlock_rest_service/sherlock_rest_service/__init__.py b/sherlock_rest_service/__init__.py similarity index 100% rename from sherlock_rest_service/sherlock_rest_service/__init__.py rename to sherlock_rest_service/__init__.py diff --git a/sherlock_rest_service/sherlock_rest_service/asgi.py b/sherlock_rest_service/asgi.py similarity index 100% rename from sherlock_rest_service/sherlock_rest_service/asgi.py rename to sherlock_rest_service/asgi.py diff --git a/sherlock_rest_service/sherlock_rest_service/settings.py b/sherlock_rest_service/settings.py similarity index 100% rename from sherlock_rest_service/sherlock_rest_service/settings.py rename to sherlock_rest_service/settings.py diff --git a/sherlock_rest_service/sherlock b/sherlock_rest_service/sherlock deleted file mode 120000 index 9a14ab8..0000000 --- a/sherlock_rest_service/sherlock +++ /dev/null @@ -1 +0,0 @@ -../sherlock \ No newline at end of file diff --git a/sherlock_rest_service/sherlock_rest_service/urls.py b/sherlock_rest_service/urls.py similarity index 100% rename from sherlock_rest_service/sherlock_rest_service/urls.py rename to sherlock_rest_service/urls.py diff --git a/sherlock_rest_service/sherlock_rest_service/wsgi.py b/sherlock_rest_service/wsgi.py similarity index 100% rename from sherlock_rest_service/sherlock_rest_service/wsgi.py rename to sherlock_rest_service/wsgi.py From 3518382d2339702b2f9209b423a2d8a87edf4066 Mon Sep 17 00:00:00 2001 From: Amusat Haki Adeyemi Date: Mon, 1 May 2023 18:10:51 +0100 Subject: [PATCH 2/2] completely working drf model --- requirements.txt | 1 + sherlock_rest_service/settings.py | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/requirements.txt b/requirements.txt index 7b3f91a..47b115f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,6 +10,7 @@ openpyxl<=3.1.2 exrex>=0.11.0 # New for this project +python-dotenv-1.0.0 Django>=3.2.10 djangorestframework>=3.13.0 gunicorn==20.1.0 diff --git a/sherlock_rest_service/settings.py b/sherlock_rest_service/settings.py index 14b93ea..87e25c2 100644 --- a/sherlock_rest_service/settings.py +++ b/sherlock_rest_service/settings.py @@ -13,31 +13,36 @@ from pathlib import Path import os + +from dotenv import load_dotenv + +load_dotenv() + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent -SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY') +SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY") if not SECRET_KEY: raise ValueError("DJANGO_SECRET_KEY environment variable is not set.") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = os.environ.get('DJANGO_DEBUG', 'False').lower() == 'true' +DEBUG = os.environ.get("DJANGO_DEBUG", "False").lower() == "true" # https://docs.djangoproject.com/en/3.0/ref/settings/#allowed-hosts ALLOWED_HOSTS = [] -RENDER_EXTERNAL_HOSTNAME = os.environ.get('RENDER_EXTERNAL_HOSTNAME') +RENDER_EXTERNAL_HOSTNAME = os.environ.get("RENDER_EXTERNAL_HOSTNAME") if RENDER_EXTERNAL_HOSTNAME: ALLOWED_HOSTS.append(RENDER_EXTERNAL_HOSTNAME) # Application definition INSTALLED_APPS = [ -# "django.contrib.admin", -# "django.contrib.auth", -# "django.contrib.contenttypes", -# "django.contrib.sessions", + # "django.contrib.admin", + # "django.contrib.auth", + # "django.contrib.contenttypes", + # "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "sherlock_api", @@ -49,7 +54,7 @@ "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", -# "django.contrib.auth.middleware.AuthenticationMiddleware", + # "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", ] @@ -78,12 +83,12 @@ # Database # https://docs.djangoproject.com/en/4.1/ref/settings/#databases -#DATABASES = { +# DATABASES = { # "default": { # "ENGINE": "django.db.backends.sqlite3", # "NAME": BASE_DIR / "db.sqlite3", # } -#} +# } # Password validation