This project makes it easy to get a Shopify app up and running with Django and the Python Shopify API.
This project simply displays basic information about the shop's products and orders.
This project has the following structure
shopify_app
an app which handles authentication (meant to be reusable)home
an app which contains the example code to demonstrate how to use the API (meant to be modified or replaced to create your Shopify App).shopify_django_app
project files for serving this app.
- Log in to your partners dashboard
- Navigate to your apps
- Click
Create App
- Choose a custom app or public app
- Fill in the app name
- Set the Application Url http://localhost:8000/
- Set Whitelisted redirection URL( http://localhost:8000/shopify/finalize/
You will then have access to your API key and API secret KEY, you will need these for the next steps.
- Create a
.env
file in the root of your project and add to it the following contents
SHOPIFY_API_KEY=[your api key]
SHOPIFY_API_SECRET=[your api secret]
-
Generate a secret key and add it to
.env
by running the following in the command line:printf 'DJANGO_SECRET=' >> .env; python -c 'import random; print("".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)]))' >> .env
- For PC Users: Run this command in GIT Bash or Windows Subsystem For Linux. Or you can generate a secret key using the Python interpreter and manually add the Django secret key to your
.env
file:
python import random print("".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])) exit()
- For PC Users: Run this command in GIT Bash or Windows Subsystem For Linux. Or you can generate a secret key using the Python interpreter and manually add the Django secret key to your
-
[Optional] you can add to
.env
the api version and api scopes environment variables:
-
SHOPIFY_API_VERSION
default isunstable
-
SHOPIFY_API_SCOPE
a comma-separated list of scopes, default isread_products,read_orders
We use pipenv to get running faster. With the
.env
already created in the root directory, run the app:
pipenv install
pipenv run python manage.py runserver
You may get warnings about migrations, but they should not stop you.
Open http://localhost:8000 in your browser to view the example.