Re: Dynamic template loader with TemplateResponse

2011-05-29 Thread Brian Morton
Here is the solution I settled on for now. This is obviously not optimally efficient because I have to hit the filesystem twice for every page load. Does anyone know of a way to raise Http404 during template rendering? I tried it with a TemplateResponse subclass but ran into some problems with _

Dynamic template loader with TemplateResponse

2011-05-23 Thread Brian Morton
I have some legacy code that I used to dynamically load a template based on url if it exists and render a 404 if it doesn't exist. def content(request, template_name='index'): try: return direct_to_template(request, '%s.html' % template_name) except TemplateDoesNotExist: r

Re: Dynamic template loader

2007-12-17 Thread Enoch
Hello Could u share your code of the new template extends tag? I have very similar problems here. Kind Regards Enoch Qin On Nov 27, 5:58 pm, jorjun <[EMAIL PROTECTED]> wrote: > OK, managed to do this in the end, by creating a new template tag and > node derived from django.template.loader_tag.

Re: Dynamic template loader

2007-11-27 Thread jorjun
OK, managed to do this in the end, by creating a new template tag and node derived from django.template.loader_tag.ExtendsNode overriding the get_parent method. Now we have total white labeling of all our templates, including base templates. Django rocks. On 27 Nov, 12:20, jorjun <[EMAIL PROTECT

Dynamic template loader

2007-11-27 Thread jorjun
I am trying to work out the best way to allow dynamic template substitution based on RequestContext Could anybody point me in the right direction? I don't know if I need a new template loader, or I need to create new tags. But in this case : {% extends "myapp/base.html" %} I would like it to l