diff --git a/.env.local b/.env.local index b182e68..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 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 diff --git a/README.md b/README.md index b468a22..8d6d122 100644 --- a/README.md +++ b/README.md @@ -35,24 +35,31 @@ 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: + +**[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: @@ -61,6 +68,50 @@ 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 +``` + + +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 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 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')