On Tue, 2009-01-27 at 20:11 +0100, Florian Lindner wrote: > Hello, > > I'm playing around with the contrib.comments framework. I want to > change the preview form. For that I've copied preview.html to xgm/Blog/ > templates/comments (xgm is my project, Blog is app). My template > loaders are: > > TEMPLATE_LOADERS = ( > 'django.template.loaders.app_directories.load_template_source', > 'django.template.loaders.filesystem.load_template_source', > ) > > But modification I make to the preview.html in my app dir does not > seem to be noticed.
The problem is that there's no ordering guarantee here. There is a comments/preview.html template provided by the django.contrib.comments app and a comments/preview.html template provided by your application. It happens that the app_directories loader runs through the applications in the order they're listed in INSTALLED_APPS at the moment, although I'm not sure that is guaranteed. For now, though, you could probably make this work by ensuring your application is listed in INSTALLED_APPS before the django.contrib.comments application. In general, another approach is to this is to use the TEMPLATE_LOADERS in the default order provided by Django (filesystem loader before app_directories loader) and put any override templates in a directory that is specified in the TEMPLATE_DIRS setting. Then the filesystem loader will be run first and is guaranteed to find your override before the app_directories loader starts its run. For comments, if you're only wanting to change the preview form for a particular model or particular application, note that the template loaded for preview is not comments/preview.html, always. That is the name that is loaded is all else fails. However, the application first looks for comments/<app>_<model>_preview.html comments/<app>_preview.html where <app> is the name of the application and <model> is the name of the model to which the comment is attached. If either of those templates are found, they are used for preference. So for an app-specific customisation for an app called "foo", say, you could create comments/foo_preview.html in the foo/templates/ directory and it will be loaded for the preview. So, there you go. Three different solutions for the same problem. Regards, Malcolm Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---