From e9040153d5477a33434c1afd357b4336b651fd5f Mon Sep 17 00:00:00 2001 From: kellykiiru Date: Sat, 16 Dec 2023 14:08:13 +0300 Subject: [PATCH 1/7] update readme with manual set up process --- README.md | 69 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b468a22..42f374b 100644 --- a/README.md +++ b/README.md @@ -35,24 +35,29 @@ for the next steps. cp .env.local .env ``` -2. Generate a secret key and add it to `.env` by running the following in the command line: - -``` -python -c 'import random; print("".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)]))' >> .env -``` - -**For PC Users:** Run this command in [GIT Bash](https://git-scm.com/) or [Windows Subsystem For Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10). Alternatively, you can generate a secret key using the Python interpreter. This requires you to manually add the Django secret key to your `.env` file by doing the following: +2. Generate a secret key and fill out the `DJANGO_SECRET` value in `.env` file by running the following in the terminal Open the python interpreter: ``` -python +python or python3 ``` Inside the python interpreter, generate the secret key, copy it, and exit: + ```python >>> import random >>> print("".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])) >>> exit() + ``` +Or use the command below in your terminal. Copy and paste the output into the value of `DJANGO_SECRET` in .env + +``` +python3 -c 'import random; print("".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)]))' >> .env +``` + + +**For Windows Users:** Run this command in [GIT Bash](https://git-scm.com/) or [Windows Subsystem For Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10). Alternatively, you can generate a secret key using the Python interpreter. This requires you to manually add the Django secret key to your `.env` file by doing the following: + 3. [Optional] you can add the api version and api scopes environment variables to the `.env` file: @@ -61,6 +66,54 @@ Inside the python interpreter, generate the secret key, copy it, and exit: * `SHOPIFY_API_SCOPE` a comma-separated list of scopes, default is `read_products,read_orders` +### Manual Setup [Optional] + +4. Create virtual environment + +For Linux and macOS + +``` +python3 -m venv virtual # 'virtual' can be any name/term +``` + +For Windows +``` +python -m venv virtual +``` + +5. Activate the virtual environment + +For Linux and macOS +``` +. virtual/bin/activate +``` +or +``` +source virtual/bin/activate +``` + +For windows +``` +source virtual\Scripts\activate + +``` + +6. Install dependencies +``` +pip install -r requirements.txt +``` + +7. Apply Migrations +``` +python3 manage.py migrate +``` + +8. Run the app +``` +python3 manage.py runserver +``` + + ### Run the App From 37131ab4080f551549abe83ce3569a3968f22a9e Mon Sep 17 00:00:00 2001 From: kellykiiru Date: Sat, 16 Dec 2023 14:09:56 +0300 Subject: [PATCH 2/7] add single quotes --- .env.local | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.env.local b/.env.local index b182e68..f2d33fe 100644 --- a/.env.local +++ b/.env.local @@ -1,3 +1,3 @@ -SHOPIFY_API_KEY= -SHOPIFY_API_SECRET= -DJANGO_SECRET= \ No newline at end of file +SHOPIFY_API_KEY="" +SHOPIFY_API_SECRET="" +DJANGO_SECRET="" \ No newline at end of file From db3415a62bd8b8aeaf08df2cef7d2fe91c2b69c9 Mon Sep 17 00:00:00 2001 From: kellykiiru Date: Sat, 16 Dec 2023 14:13:30 +0300 Subject: [PATCH 3/7] update django and other project dependencies --- requirements.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index e26e3e4..e5a072c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ -asgiref==3.2.10 -Django==3.0.8 +asgiref==3.7.2 +Django==5.0 pyactiveresource==2.2.1 +python-dotenv==1.0.0 pytz==2020.1 PyYAML==5.3.1 ShopifyAPI==8.0.1 From 54acc0fbf8b973e6d818d0d6bcdb3ac23d99b1bd Mon Sep 17 00:00:00 2001 From: kellykiiru Date: Sat, 16 Dec 2023 14:14:59 +0300 Subject: [PATCH 4/7] install python-dotenv to access environment variables --- shopify_app/apps.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/shopify_app/apps.py b/shopify_app/apps.py index 9a52b53..4eb2c17 100644 --- a/shopify_app/apps.py +++ b/shopify_app/apps.py @@ -1,5 +1,8 @@ from django.apps import AppConfig import os +from dotenv import load_dotenv + +load_dotenv() class ShopifyAppConfig(AppConfig): @@ -15,8 +18,8 @@ class ShopifyAppConfig(AppConfig): # # You can ignore this file in git using the following command: # git update-index --assume-unchanged shopify_settings.py - SHOPIFY_API_KEY = os.environ.get('SHOPIFY_API_KEY') - SHOPIFY_API_SECRET = os.environ.get('SHOPIFY_API_SECRET') + SHOPIFY_API_KEY = os.environ['SHOPIFY_API_KEY'] + SHOPIFY_API_SECRET = os.environ['SHOPIFY_API_SECRET'] # API_VERSION specifies which api version that the app will communicate with SHOPIFY_API_VERSION = os.environ.get('SHOPIFY_API_VERSION', 'unstable') From 90555555fcf5c93eeaea0c6cbaf0c2e001f97f01 Mon Sep 17 00:00:00 2001 From: kellykiiru Date: Sat, 16 Dec 2023 14:16:37 +0300 Subject: [PATCH 5/7] update gitignore with virtual environments --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 3025cb9..e9a5df1 100644 --- a/.gitignore +++ b/.gitignore @@ -88,3 +88,6 @@ local_settings.py .env db.sqlite3 +#virtual environments +venv +virtual \ No newline at end of file From 4c5abd066cbff4b03a7ae12907a8449f018931c2 Mon Sep 17 00:00:00 2001 From: kellykiiru Date: Sat, 16 Dec 2023 14:17:33 +0300 Subject: [PATCH 6/7] add single quotes to house values --- .env.local | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.env.local b/.env.local index f2d33fe..27d6778 100644 --- a/.env.local +++ b/.env.local @@ -1,3 +1,3 @@ -SHOPIFY_API_KEY="" -SHOPIFY_API_SECRET="" -DJANGO_SECRET="" \ No newline at end of file +SHOPIFY_API_KEY='' +SHOPIFY_API_SECRET='' +DJANGO_SECRET='' \ No newline at end of file From d064ed0723c96be0583a345d14e2e3f6e49ede6a Mon Sep 17 00:00:00 2001 From: kellykiiru Date: Sat, 16 Dec 2023 16:41:56 +0300 Subject: [PATCH 7/7] update readme --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 42f374b..8d6d122 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ python3 -c 'import random; print("".join([random.choice("abcdefghijklmnopqrstuvw **For Windows Users:** Run this command in [GIT Bash](https://git-scm.com/) or [Windows Subsystem For Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10). Alternatively, you can generate a secret key using the Python interpreter. This requires you to manually add the Django secret key to your `.env` file by doing the following: +**[For Windows OS]:** Use ```python``` instead of ```python3``` in CMD + 3. [Optional] you can add the api version and api scopes environment variables to the `.env` file: @@ -76,10 +78,6 @@ For Linux and macOS python3 -m venv virtual # 'virtual' can be any name/term ``` -For Windows -``` -python -m venv virtual -``` 5. Activate the virtual environment