Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kelly #68

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .env.local
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SHOPIFY_API_KEY=
SHOPIFY_API_SECRET=
DJANGO_SECRET=
SHOPIFY_API_KEY=''
SHOPIFY_API_SECRET=''
DJANGO_SECRET=''
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,6 @@ local_settings.py
.env
db.sqlite3

#virtual environments
venv
virtual
67 changes: 59 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions shopify_app/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from django.apps import AppConfig
import os
from dotenv import load_dotenv

load_dotenv()


class ShopifyAppConfig(AppConfig):
Expand All @@ -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')
Expand Down