Closed TrangPham closed 2 years ago
cache_control was introduced for: fix(MR-16): Use cache for FileField and ImageField (#17)
Tested on Django 3.2 locally and issue seems to not be happening
Issue persists on Django 4.0.4 when code was updated to use method_decorator:
#
from django.utils.decorators import method_decorator
#
from django.views.decorators.cache import cache_control
from admin_confirm.constants import (
CONFIRMATION_RECEIVED,
CONFIRM_ADD,
CONFIRM_CHANGE,
SAVE,
SAVE_ACTIONS,
CACHE_KEYS,
SAVE_AND_CONTINUE,
SAVE_AS_NEW,
CACHE_TIMEOUT,
)
from admin_confirm.file_cache import FileCache
#
@method_decorator([cache_control(private=True)], name="dispatch")
#
class AdminConfirmMixin:
# Should we ask for confirmation for changes?
confirm_change = None
# Should we ask for confirmation for additions?
confirm_add = None
# If asking for confirmation, which fields should we confirm for?
confirmation_fields = None
# Custom templates (designed to be over-ridden in subclasses)
change_confirmation_template = None
action_confirmation_template = None
_file_cache = FileCache()
...
# @cache_control(private=True)
def changeform_view(self, request, object_id=None, form_url="", extra_context=None):
if request.method == "POST":
Hello @TrangPham , Some news respecting this bug?
There’s no update on this bug at the moment. Are you experiencing this bug and if so can you post your versions?
@Rigo-Villalta I took another look at this. The solution is included in PR #36.
For reference, this is what changed:
@method_decorator(cache_control(private=True))
def changeform_view(self, request, object_id=None, form_url="", extra_context=None):
method_decorator needed to be applied on the function for instance functions, instead of on the class (which is only used for class methods I think?) https://github.com/TrangPham/django-admin-confirm/pull/36/files#diff-fd78a9569df4114b07e16d4cf9412096e8e88adb42a9e199eb28cd95d1db04c9L105
Thank you for that, unfortunately, this is not up-to-date on official repo https://pypi.org/project/django-admin-confirm/ . Could be nice to post the v1 of your nice work!
@guiklimek Thanks for your comment! Look like I forgot to push it to pypi. I'll try to get the testing and push done this week.
Describe the bug Project doesn't work with Django 4.0.4
To Reproduce Steps to reproduce the behavior: Using Django 4.0.4
Additional context