Changes between Version 7 and Version 8 of TemplatePitfalls


Ignore:
Timestamp:
09/14/2005 07:12:34 AM (10 years ago)
Author:
garthk
Comment:

Response to L.Plant.98

Legend:

Unmodified
Added
Removed
Modified
  • TemplatePitfalls

    v7 v8  
    3535If your needs are middling simple, or you don't want to have to write your own custom template tag from scratch, I've developed a generic option: [http://www.deadlybloodyserious.com/categories/django/2005/09/06.html vars],  which defines a fairly generic {{{pushvars}}} tag that calls the function of your choice and pushes its results into the current context.
    3636
    37 I'm posting this to atone for my previous crummy advice on this Wiki page.
    38 
    39 {{{- garthk}}}
     37I'm posting this to atone for my previous crummy advice on this Wiki page. {{{- garthk}}}
    4038
    4139''But what if your custom template tags needs access to the HttpRequest object in order to do it's stuff?  For example, if you have a menu or a breadcrumb that depends on request.path, or on the session etc?  Does the DjangoContext object provide access to this in any way?  The only ways I've found are things like subclassing DjangoContext and getting that to use the request to create any data needed for the base templates/custom template tags, but that won't work with generic views AFAIK.  (I'm happy using my current method, as I haven't actually used generic views yet, but imagine I may need to soon). Cheers.''
    4240
     41I had a chat to Adrian about that. They haven't yet seen a compelling reason to have {{{DjangoContext}}} stash a copy of {{{request}}}, and indeed it turned out that there was an easy workaround to my use case (access to the request path for my login system). If you have a good use case, submit a ticket. {{{ - garthk }}}
Back to Top