djangosnippets.org: Latest snippets posted by trbshttps://djangosnippets.org/users/trbs/2008-06-01T13:18:30.959528-05:00trbsManyToManyFieldWithDefault
2008-06-01T13:18:30.959528-05:00trbshttps://djangosnippets.org/snippets/780/<p>Extension to the normal ManyToManyField to support default values.</p>
<p>Build for the following use case:</p>
<p>publish_on = ManyToManyFieldWithDefault(Site, verbose_name=_('publish on'), default=Site.objects.get_current)</p>
<p>Where with a plain ManyToManyField the default site will not be selected. The ManyToManyFieldWithDefault fixes this by automatically selecting the default value if no other selections are given.</p>
<p>When …</p>
Freely redistributablePaginator TemplateTag
2008-03-28T20:16:03.927075-05:00trbshttps://djangosnippets.org/snippets/673/<p><strong>Paginator TemplateTag</strong>
</p>
<p>TemplateTag to use the new Paginator class directly from a template.
The paginate template tags take the following options:
</p>
<ol>
<li>
list or queryset to paginate
</li>
<li>
number of pages
</li>
<li>
[optionaly] name of the Paginator.Page instance; prefixed by keyword 'as'
</li>
<li>
[optionaly] name of the http parameter used for paging; prefixed by …</li></ol>
Freely redistributableUUIDField
2007-07-22T20:53:55.999509-05:00trbshttps://djangosnippets.org/snippets/335/<p>UUIDField is a field which stores an uuid generated by pythons new uuid module.</p>
<p>it's included with the python 2.5 distribution by default, but if you run an older version of python you can happily copy the file from 2.5 to django/utils/uuid.py or your project directory.</p>
Freely redistributabletruncate letters
2007-03-23T00:36:13.966784-05:00trbshttps://djangosnippets.org/snippets/126/<p>filter for truncating strings similar to truncatewords only with letters.</p>
Freely redistributableStrip html comments middleware
2007-03-21T18:13:42.195217-05:00trbshttps://djangosnippets.org/snippets/123/<p>Middleware for stripping all html comments from the response content before returning it to the client.</p>
<p>This will also strip inline javascript with htmlcomments put around it!</p>
Freely redistributable