[Answered ]-Django: After updating a template, the changes are not reflected upon refreshing the page in the browser

1๐Ÿ‘

โœ…

I guess your template is only loaded during initialization:

loader.get_template('myapp/all.html')

You can try the following, which is also suggested by the django documentation:

class AllView(View):
   template_name = 'myapp/all.html'

    def get(self, request, *args, **kwargs):
        return render(request, self.template_name)

Of if you only need to render a template, you can use the TemplateView:

from django.views.generic import TemplateView

class AboutView(TemplateView):
    template_name = 'myapp/all.html'
๐Ÿ‘คMarco

0๐Ÿ‘

I believe there is something with how you are rendering the template through the loader, the template files by default are read from disk on every request, so there is no need to restart anything, if you are only rendering a template, I suggest you to use TemplateView

from django.views.generic.base import TemplateView


class AllView(TemplateView):
    template_name = "myapp/all.html"

There is a caching template loader, but it is disabled by default. See the documentation for more info.

Leave a comment