discolabs / django-shopify-sync

A package for synchronising Django models with Shopify resources. Unmaintained.
Other
3 stars 4 forks source link

AttributeError in base.py - Session object has no attribute 'model' #2

Closed ericduq closed 7 years ago

ericduq commented 7 years ago

@sydhenry

I'm getting an AttributeError when running:

products = Product.objects.sync_all(query="Foo bar",session=sess)

The raised error is:

... in sync_one
defaults.update({'session': shopify_resource.session.model})
AttributeError: 'Session' object has no attribute 'model'

The error flows back to base.py. The applicable section of code in base.py is (@sydhenry's fork):

try:
    instance, created = self.update_or_create(id=shopify_resource.id,
                                              defaults=defaults)
except (utils.IntegrityError, Session.DoesNotExist):
    # This means that there needs to be the session in the defaults
    if isinstance(shopify_resource.session, ShopifySession):
        defaults.update({'session': shopify_resource.session.model})
    else:
        defaults.update({'session': shopify_resource.session})
    instance, created = self.update_or_create(
        id=shopify_resource.id,
        defaults=defaults,
    )

This is the first time I've used the package. I've properly migrated and have verified that I can access the client's products with just the shopify module.