Create a shopify app with django
Here, we will see how we can create a basic shopify app with django.
- Install Django and the Django Shopify Auth package:
pip install django
pip install django-shopify-auth
2. Create a django project and install apps. I will not go through the full process. You can go through this link for the basics: “https://docs.djangoproject.com/en/4.1/intro/tutorial01/”
3. Add the shopify_auth
and shopify_app
apps to your Django project's INSTALLED_APPS
list in the settings.py
file:
INSTALLED_APPS = [ ... 'shopify_auth', 'shopify_app',]
4. Set the SHOPIFY_APP_NAME
and SHOPIFY_APP_API_KEY
settings in your settings.py
file. The SHOPIFY_APP_NAME
should be the name of your app as it will appear in the Shopify App Store, and the SHOPIFY_APP_API_KEY
is the API key that you will use to authenticate your app with Shopify.
5. Include the shopify_auth.urls
and shopify_app.urls
URL patterns in your Django project's urls.py
file:
urlpatterns = [
...
path('shopify_auth/', include('shopify_auth.urls')),
path('shopify_app/', include('shopify_app.urls')),
]
6. Run the following Django management commands to create the required database tables:
python manage.py migrate
python manage.py createsuperuser
7. Create a new private app in your Shopify store’s developer dashboard. Set the app’s Redirection URL
to the login
URL of the shopify_auth
app (e.g. http://localhost:8000/shopify_auth/login
).
8. Set the SHOPIFY_APP_API_SECRET
setting in your settings.py
file to the API secret provided by your private app.
9. Start the Django development server and visit the login
URL of the shopify_auth
app (e.g. http://localhost:8000/shopify_auth/login
) to begin the authentication process.
That’s it! You should now have a basic Shopify app running on Django. You can use the Django Shopify Auth package to handle the authentication process and the Django Shopify App package to access the Shopify API and build out the functionality of your app.
I hope this helps! Let me know if you have any questions.