Ok, thanks everyone for the replies. I will take a look at these suggestions.
On May 13, 6:06 am, Michal Petrucha <michal.petru...@ksp.sk> wrote: > On Thu, May 12, 2011 at 08:15:59PM -0700, robinne wrote: > > How can I render dynamic content in a base template if I only call a > > view on my child template? > > > What I am trying to do is setup a base template that will include > > "Profile" information for the user who is logged in, for example: > > "Welcome John", instead of "login here", on every page. But if I call > > my child page "/Home" (for example) and it extends "base.html", how do > > I render the dynamic content within base.html? Thanks. > > You can use either custom template tags as suggested by others. The > alternative is to create custom context processors that will add > dynamic data you want to display into the context. Then you can use it > even in your base template. However, you'll have to make sure each > view uses a RequestContext when rendering templates in order for the > context processors to be applied. > > As for the specific problem you're solving, RequestContext already > contains user data which means you don't need anything extra. Just > check in your base template if a user is logged in and show his > username if yes or a login link otherwise. > > Michal > > signature.asc > < 1KViewDownload -- 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.