djangosnippets.org: Latest snippets posted by forgemshttps://djangosnippets.org/users/forgems/2009-06-09T07:10:43.554405-05:00forgemsFiltering foreignkey fields in django admin
2009-06-09T07:10:43.554405-05:00forgemshttps://djangosnippets.org/snippets/1558/<p>Sometimes you need to filter foreignkey choices in admin interface, to objects created by user or meeting some other condition. In django 1.0 there is no formfield_for_foreignkey method in ModelAdmin class so we have to make a workaround. Here is the solution I have found to be the easiest for …</p>
Freely redistributableinclusion tag with template as variable
2009-02-19T05:05:25.269465-06:00forgemshttps://djangosnippets.org/snippets/1329/<p>Sometimes you need to write a tag that renders other template, but the template name depends on template tag arguments. Usually you use simple_tag or write your own Node class. Here is a simple aproach that uses inclusion_tag. This way you can use context objects when used with takes_context=True</p>
Freely redistributablecaching parsed templates
2007-12-12T14:18:48.635038-06:00forgemshttps://djangosnippets.org/snippets/507/<p>Put this code somewhere in one of your INSTALLED_APPS <code>__init__.py</code> file. This code will replace the django.template.loader.get_template with cached version. Standard get_template function from django reads and parses the template code every time it's called. This version calls (if DEBUG set to False) it only once per template. After that …</p>
Freely redistributable