On Jun 23, 9:47 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Tue, Jun 23, 2009 at 8:34 PM, nbv4 <cp368...@ohio.edu> wrote: > > > I'm trying to set up a template for all my forms, but I'm having > > trouble using the {% with %} block: > > > {% extends "base_form.html" %} > > {% with form.instance as object %} > > > {% block title%} > > {{object.title}} <- not displayed :( > > {% endblock %} > > > {% block body %} > > {% with form.instance as object %} > > {{object.title}} <- now it is displayed > > {% endwith%} > > {% endblock %} > > > {% endwith %} > > > The 'with' tag works, but only within other blocks. Is there any way > > to get around this without wrapping a hundred 'with' blocks around > > each block in my template? > > I don't think what you're describing has anything to do with the {% with %} > tag specifically. You're dealing with a child template here -- one that > starts with an {% extends %} tag. Nothing placed outside of {% block %} > tags in a child template has any effect on the rendered template. A child > template simply supplies block contents to override what has been specified > in the parent template, so everything in a child template must be included > inside {% block %} tags. (If it is not specified inside a {% block %}, where > should it go in the parent template?) See: > > http://docs.djangoproject.com/en/dev/topics/templates/#id1 > > Karen
Yes, but {% with %} isn't placing anything anywhere. It's just creating a new variable "object" from "form.instance". My only options seems to be either stuck using form.instance, or place a {% with %} tag inside each and every {% block %} that needs it (which is just about every one). I don't like either option :( --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---