I am trying to extend a template. My parent Template is in mysite/mytemplates/promotions/ and the child template is in mysite/mytemplates/polls/ I get the following error saying that the template cannot be found when I try:- {% extends "mytemplates/promotions/promotion_list.htm" %} The error reads:- In template c:/python24/lib/site-packages/django/bin/mysite/mytemplates\polls/index.html, error at line 1 Template 'mytemplates/promotions/promotion_list.html' cannot be extended, because it doesn't exist 1 It's strange that the error message is showing that the slash after mytemplates ichanges to a backslash from a forward slash. I'm wondering if I have something wrong with my setup because I've also noticed I can't run any javascripts - even though they seem to be installed in the right directory. That said, I have other templates (which are not child templates) which load fine within the promotions directory and the polls directory. MerMer --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~--- |
I've now moved the parent template into the same directory as the child template but I'm still getting the same error. Exception Value: Template 'results.html' cannot be extended, because it doesn't exist Exception Location: C:\Python24\lib\site-packages\django_src\django\template\loader_tags.py in get_parent, line 58 Template error In template c:/python24/lib/site-packages/django/bin/mysite/mytemplates\polls/index.html, error at line 1 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~--- |
I think templates to be inherited must be on the base template dir... I remember reading this somewhere but can't find references online. Can you test please? On 10/12/06, MerMer <[hidden email]> wrote: > > I've now moved the parent template into the same directory as the child > template but I'm still getting the same error. > -- Julio Nobrega - http://www.inerciasensorial.com.br --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~--- |
In reply to this post by MerMer
On Thu, 2006-10-12 at 05:36 -0700, MerMer wrote: > I am trying to extend a template. My parent Template is in > mysite/mytemplates/promotions/ > and the child template is in mysite/mytemplates/polls/ > > I get the following error saying that the template cannot be found when > I try:- > > {% extends "mytemplates/promotions/promotion_list.htm" %} What does your TEMPLATE_DIRS setting look like? It seems like the above path to your template is way too long for any likely settings you would have there. The argument in the {% extends ... %} tag is appended to each of the prefixes in TEMPLATE_DIRS in turn until the file is found (if no success, the error you see is raised). So I suspect you have the name of the template incorrect in the above line. 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 [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~--- |
my settings look like the following:- TEMPLATE_DIRS = ( "c:/python24/lib/site-packages/django/bin/mysite/mytemplates", When I set up Django I just put in the full path in the belief that this would make things easier while I was testing stuff. MerMer --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~--- |
In reply to this post by Julio Nobrega
Julio, I not sure what directory you're refering to. The tutorial is quite explicit that one should create your own template directory within your site. It wouldn't make any sense if these then had to refer to base templates elsewhere. MerMer --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~--- |
In reply to this post by MerMer
On Oct 12, 2006, at 8:03 AM, MerMer wrote: > > my settings look like the following:- > > TEMPLATE_DIRS = ( > "c:/python24/lib/site-packages/django/bin/mysite/mytemplates", > > When I set up Django I just put in the full path in the belief that > this would make things easier while I was testing stuff. you previously wrote: > {% extends "mytemplates/promotions/promotion_list.htm" %} If your template library is called 'mytemplates', then don't use that part of the path in the extends call. Your extends call should only specify the rest of the path needed to find the file (essentially, the system should be able to join the TEMPLATE_DIRS path and the extends path to find the file). So your extends should read: {% extends "promotions/promotion_list.htm" %} You don't necessarily need to use a full path in your TEMPLATE_DIRS. If the template folder is directly inside the project folder, you can simply code that folder name. Don --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~--- |
Don, Thanks for the advice - but it's not working for me. My full path is "c:/python24/lib/site-packages/django/bin/mysite/mytemplates" which works. I've tried "/mytemplates" and "mysite/mytemplates" as the TEMPLATE_DIR path but they don't. The {% extends "promotion_list.htmt"%} is not working even when I moved the promotion_list template into the same directory as the child template. I'm probably making some realy rookie mistake - but I can't see it. MerMer --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~--- |
On Oct 12, 2006, at 12:29 PM, MerMer wrote: > > Don, > > Thanks for the advice - but it's not working for me. > > My full path is > "c:/python24/lib/site-packages/django/bin/mysite/mytemplates" which > works. > > I've tried "/mytemplates" and "mysite/mytemplates" as the TEMPLATE_DIR > path but they don't. > > The {% extends "promotion_list.htmt"%} is not working even when I > moved > the promotion_list template into the same directory as the child > template. > > I'm probably making some realy rookie mistake - but I can't see it. > MerMer Your TEMPLATE_DIR should not have a leading '/' otherwise the system will be looking for a top level directory, meaning that it will treat it as a full path (also known as an absolute path). You should code it as 'mytemplates' (this is a relative path, and Django will look for it relative to your project folder). On a different note, I wouldn't put my project folder into Django's bin folder. That folder's purpose is to store scripts used for maintaining Django. Nothing particularly wrong with that, but I liken it to storing food in my bathroom (a place for everything and everything in its place). Don --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~--- |
I've now got the TEMPLATE_DIR as 'mytemplates' and that's fixed it. Your advice on what is an absolute and relative path was very helpful. Many thanks. Based on the above, could you give me some examples on what my Media Root and URL, and Admin Media Prefix should be. I think I'm also having issues with those. Cheers MerMer --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~--- |
Free forum by Nabble | Edit this page |