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

Error in product.invalidate_cache() for product change #826

Open
virtgen opened this issue Jul 11, 2020 · 0 comments
Open

Error in product.invalidate_cache() for product change #826

virtgen opened this issue Jul 11, 2020 · 0 comments

Comments

@virtgen
Copy link

virtgen commented Jul 11, 2020

While changing the product the following exception occurs:

self.save_model(request, new_object, form, not add)
File "/usr/local/lib/python3.6/site-packages/shop/admin/product.py", line 125, in save_model
product.invalidate_cache()
File "/usr/local/lib/python3.6/site-packages/shop/models/product.py", line 373, in invalidate_cache
cache.delete_pattern('product:{}|*'.format(self.id))
AttributeError: module 'django.core.cache' has no attribute 'delete_pattern'


Tested on demo shop made by cookiecutter for nginx docker and Redis cache selected.


Direct reason is using the following import:

  • 'from django.core import cache'
    instead of
  • 'from django.core.cache import cache'

Potential workaround is to override invalidate_cache() with proper import in custom product for user ‘myshop’ project but this is not right solution and should be fixed in django-shop.

execut added a commit to execut/django-shop that referenced this issue Dec 25, 2020
jrief added a commit that referenced this issue Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant