djangosnippets.org: Latest snippets posted by realmachttp://djangosnippets.org/users/realmac/2011-09-15T06:03:43.615522-05:00realmacSelectRelatedManager
2011-09-15T06:03:43.615522-05:00realmachttp://djangosnippets.org/snippets/2548/<p>Because select_related() only works on ForeignKeys that are not null or blank, when you are customizing the admin, even if you set "list_select_related=True" you can still end up with way too many querys in the Admin changelist. By adding this code to your model you can decrease the queries dramatically. …</p>
Freely redistributableMake anything into a template
2008-02-06T00:35:25.188202-06:00realmachttp://djangosnippets.org/snippets/586/<p>This is a quick and dirty way to reuse the Django templating system for your own ends. Just pop in the familiar Django template syntax into whatever content you like and any chunk of content can be a template. This is great if you need to wrap data in HTML …</p>
Freely redistributableAge - custom filter
2008-01-21T15:23:52.410395-06:00realmachttp://djangosnippets.org/snippets/557/<p>Based on the discussion at Empty Thoughts (http://blog.michaeltrier.com/2007/8/6/age-in-years-calculation) I built a quick and dirty custom filter.</p>
<p>Save this as a file in your "templatetags" folder. I called mine "calculate_age.py" and then in your template "{% load calculate_age %}" then use it, "{{ object.birthdate|age }}"</p>
Freely redistributable