djangosnippets.org: Latest snippets posted by celopeshttps://djangosnippets.org/users/celopes/2010-08-08T14:12:17.879873-05:00celopesA ModelChoiceField with support for title in options based on a field in the model
2010-08-08T14:12:17.879873-05:00celopeshttps://djangosnippets.org/snippets/2142/<p>ModelChoiceTitleField is a ModelChoiceField descendent that creates <OPTIONS> with title elements based on the field specified in title_source_field:
</p>
<pre><code>priority=ModelChoiceTitleField(Priority.objects.all(),
initial=Priority.objects.get(default=True).id,
title_source_field='long_description')
</code></pre><p>That will generate a <code><SELECT></code> element looking like:
</p>
<pre><code><select name="priority" id="id_priority">
<option value="1" title="Some extremely important task.">Emergency</option>
...
</select>
</code></pre><p>In the <code><option></code> above, the title was retrieved from the …</p>
Freely redistributableTemplate tag to create mailto links with options
2009-06-19T12:19:55.531450-05:00celopeshttps://djangosnippets.org/snippets/1581/<p>A {% mailto %}{% endmailto %} template tag that requires an e-mail destination and optionally accepts subject, cc and bcc. It will then wrap whatever is within the tag in an <code><a href="mailto:..."> </a></code> HTML tag.</p>
<p>See the docstring in the code for the {% mailto %} usage and some …</p>
Freely redistributable