The Python Oracle

Django doesn't update HTML template after `model.save()`

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Mysterious Puzzle

--

Chapters
00:00 Django Doesn'T Update Html Template After `Model.Save()`
01:10 Answer 1 Score 0
01:22 Accepted Answer Score 4
01:41 Thank you

--

Full question
https://stackoverflow.com/questions/5488...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#javascript #python #ajax #django #djangorestframework

#avk47



ACCEPTED ANSWER

Score 4


Try adding the "never_cache" decorator to the view reponsible for page rendering:

from django.views.decorators.cache import never_cache

@never_cache
def myview(request, ...):
   ...

or to the dispatch method if it's a CBV:

class MyView(View):

    @never_cache
    def dispatch(self,request,*args,**kwargs):
        return super().dispatch(request,*args,**kwargs)



ANSWER 2

Score 0


Can you try to use location.reload(true). Maybe it takes page from cash.