djangosnippets.org: Latest snippets posted by trbshttps://djangosnippets.org/users/trbs/2008-06-01T13:18:30-05:00trbsManyToManyFieldWithDefault2008-06-01T13:18:30-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 ...</p>
Freely redistributablePaginator TemplateTag2008-03-28T20:16:03-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 ...</li></ol>
Freely redistributableUUIDField2007-07-22T20:53:55-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 ...</p>
Freely redistributabletruncate letters2007-03-23T00:36:13-05:00trbshttps://djangosnippets.org/snippets/126/<p>filter for truncating strings similar to truncatewords only with letters.</p>
Freely redistributableStrip html comments middleware2007-03-21T18:13:42-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