A package for synchronising Django models with Shopify resources.
Project description
This is a maintained fork of https://github.com/discolabs/django-shopify-sync
Installation
pip install django-shopify-sync
Add
'shopify_sync',
toINSTALLED_APPS
Create a new
shopify_sync.Session
in Django admin or shell, enter your Shopify admin API token and site name.
Where to get these fields:
API Token: In the Shopify admin, this is caleld “API Key Password”.
Site name: If your domain is http://my-site.myshopify.com your site name is my-site.
This package supports Python 3.X and Django>=1.11
How to use
First we will get some of the products from shopify
from shopify_sync.models import Product, Session
session = Session.objects.first() # Assuming you have just one that you made previously
products = Product.objects.sync_all(session, query="For bar")
sync_all
passes all kwargs to the shopify_resource.find
so we can
then sync only the items that shopify returns from that search. Now we have all
of the products
stored locally. Now to update from Django
product = Product.objects.first()
product.title = "New Bar Foo"
product.save(push=True)
The save
method on the objects also accepts the optional argument push
which will push the updated model that is locally to Shopify. Now if a product
was edited on shopify through some means other than this Django app, we will
not have the current updated model. For this we need to sync
changed_product.sync()
the changed_product
will get a local copy of the shopify_resource and then
do a .reload()
on it so that we make a request to shopify. Then we sync
that back with our database.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-shopify-sync-2.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a60de85acdd6fb4894f9151a97ad6c2b5f9d2626cfa0981f46f5c700f3ed8d94 |
|
MD5 | 3a71842356f94b2b31ab2e85da6ad4e7 |
|
BLAKE2b-256 | 1f61cee2b10c4b9e65f809169c5ff0a62b914383f11d15536bcf156857e2946f |
Hashes for django_shopify_sync-2.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f1770b2a727c471bf6e747803cfc89cfcf1d4deb49a9b1beb0756ad73831908 |
|
MD5 | eca5b449f84146c52b592a60d6f6499b |
|
BLAKE2b-256 | 1d8956d004ecc9c107bda0f632cef6b23c258bb7de476191b29b5eb4e41a5e1d |