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.
๐คAlejandro Franco
- [Answered ]-Modify the raw url of Django request before all the normal processes
- [Answered ]-Django admin:custom search
- [Answered ]-Django on AWS EC2 โ Do I need anything installed on my local computer?
- [Answered ]-Nginx authenticate iframe
Source:stackexchange.com