djangosnippets.org: Latest snippets tagged with 'lazy'https://djangosnippets.org/tags/lazy/2013-12-12T03:57:44.527969-06:00Lazy context processor.
2013-12-12T03:57:44.527969-06:00spookylukeyhttps://djangosnippets.org/snippets/3011/<p>Sometimes you have context variables that are needed on many pages in a site, but not all. You only want them to be evaluated when actually needed, especially if they are expensive calculations that do DB queries etc. The pattern to use is shown: put a callable into the context, …</p>
Freely redistributableFieldStack - easy form template rendering
2010-05-26T16:53:42.284344-05:00divermanhttps://djangosnippets.org/snippets/2040/<p>FieldStack simplifies forms template rendering. This is enhanced version of snippet <a href="http://djangosnippets.org/snippets/1786/">1786</a></p>
Freely redistributableLazily lookup dynamically for templates
2008-03-08T14:32:31.506540-06:00axiakhttps://djangosnippets.org/snippets/632/<p>If you've ever wanted to dynamically lookup values in the template layer (e.g. <code>dictionary[bar]</code>), then you've probably realized/been told to do this in the python layer. The problem is then you often to build a huge 2-D list to hold all of that data.</p>
<p>These are two solutions to …</p>
Freely redistributablelazy url reverse()
2007-12-07T15:07:25.951376-06:00guettlihttps://djangosnippets.org/snippets/499/<p>Since the decorators of your views are evaluated during parsing urls.py you have an 'chicken - egg' problem. The method reverse() can't be used since urls.py is not read.</p>
<p>This snippets evaluates reverse() lazy.</p>
<p><a href="http://code.djangoproject.com/ticket/5925">Related ticket: 5925</a></p>
<p>Django 1.4 (current trunk) has a lazy reverse.</p>
Freely redistributable