awesto / django-shop

A Django based shop system
http://www.django-shop.org
BSD 3-Clause "New" or "Revised" License
3.17k stars 1.04k forks source link

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

Open virtgen opened 3 years ago

virtgen commented 3 years ago

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:


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.