Malcolm Tredinnick wrote: > On Fri, 2009-01-09 at 14:00 +0100, Olivier Guilyardi wrote: >> Hi, >> >> We have developed Telemeta, a "pluggable" Django application (to be added to >> INSTALLED_APPS). It works great. We now need to support per-project templates >> customization as one can do for the admin. >> >> Telemeta provides a bunch of default templates. Once one has created a new >> django project, and installed telemeta, there is a need to customize the >> templates for this particular project. >> >> So, as it's done for the admin in my_project/templates/admin, I would like to >> make it possible to create a my_project/templates/telemeta directory and put >> customized templates in there, overloading default templates. >> >> How can I add support for this optional templates/telemeta directory, >> automatically, whenever one has installed telemeta ? > > The telemeta source would need to support this directly, by passing a > list of template names to render_to_response() (not just a single > template name). Have a look at the usage of render_to_response() in > django/contrib/admin/options.py, for example. > > Alternatively, it could use select_template() as documented in [1]. > Particularly, see the "Tip" in that piece of documentation. That > describes the method used. > > [1] > http://docs.djangoproject.com/en/dev/ref/templates/api/#the-python-api
Thanks for this pointer. But I actually didn't read, or forgot, the very next sentence after this tip: "It's possible -- and preferable -- to organize templates in subdirectories of the template directory. The convention is to make a subdirectory for each Django app, with subdirectories within those subdirectories as needed.". This is exactly how it's done for the admin, the templates reside in django/contrib/admin/templates/admin and not in django/contrib/admin/templates. So I've moved all of telemeta templates from telemeta_app/templates into telemeta_app/templates/telemeta, which looks cleaner to me, to avoid conflict with templates from the project or other apps. But when I add a customized template into my_project/templates/telemeta, the customizations are invisible. I must add that the default template I'm trying to overload is itself extending another template. So maybe that this problem relates to the extend functionality ? For instance, in the admin, this seems addressed in: http://code.djangoproject.com/browser/django/tags/releases/1.0.2/django/contrib/admin/views/template.py#L56 Should I replace the "extends" tag as well ? You can read the telemeta template that I'm trying to extend here: http://telemeta.org/browser/trunk/telemeta/templates/telemeta/mediaitem_detail.html?rev=335 Regarding render_to_response() with multiple templates or select_template(), by reading admin's options.py it looks to me like this shouldn't be necessary. By using render_to_response('telemeta/mediaitem_detail.html') the template loader should automatically look for my_project/templates/telemeta/mediaitem_detail.html and then for telemeta_app/templates/telemeta/mediaitem_detail.html. Am I wrong ? > Since the Telemeta website seems to be crashing at the moment, I can't > see if they're set up to support that or not, but a quick search through > the source should reveal the details. This is only a random crash, which we're in the process of fixing. Please click reload, it should work ok. -- Olivier Guilyardi / Samalyse --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---