On Thu, Sep 18, 2008, Daniel Roseman <[EMAIL PROTECTED]> wrote: >> >> I have a base.html template. >> >> >> In it I've inserted: >> >> >> {% block stylesheets %}{% endblock %} >> >> >> and in stylesheets.html in the same directory: >> >> >> {% extends "base.html" %} >> >> {% block stylesheets %} >> >> <--- my styles ---> >> >> {% endblock %} >> >> >> But the {% block stylesheets %} in stylesheets.html isn't filling in the >> >> block in base.html - obviously I'm missing something simple here; what >> >is it?
>> >You don't show how you're calling this template from your view. Are >> >you sure you're rendering the child template (stylesheets.html) rather >> >than base.html? >> >> base.html is successfully rendered. >But the fact that you're saying 'base.html is successfully rendered' >leads me to suspect that you're doing something like: >return render_to_response('base.html', context) >This will only ever show the contents of base.html, since inheritance >works in the other direction. If you want to display the contents of >stylesheet.html, you need to call render or render_to_response on >*that* template, and Django will walk up the chain of 'extends' tags >to include base.html as well. Maybe if I explain what I'm doing it will help. Django CMS uses a base template, base.html. base.html is: <http://trac.django-cms.org/trac/browser/trunk/cms/templates/cms/base.html> What I would like is to devolve bits of it to child templates. So instead of listing stylesheets in the <head>, I thought I would be able to insert a: {% block stylesheets %}{% endblock %} in the head, and place the stylesheets in a block in a template that extends base.html. At any rate, this is what I gathered was the way to do this. This way - I thought - I'd be able to have blocks available for things that can sensibly be reused in different templates, like stylsheets, navigation menus, and so on. But clearly I'm missing some conceptual leap. By the way - having been looking at older documentation and discussion of this, it used to be that: {% extends "whatever.html" %} was once: {% extends "whatever" %} See for example: <http://jeffcroft.com/blog/2006/feb/25/django-templates- the-power-of-inheritance/> Was this changed so that any filename extension could be used, not just .html? Daniele --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---