djangosnippets.org: Latest snippets posted by xuqingkuanghttps://djangosnippets.org/users/xuqingkuang/2009-10-23T08:08:47.689832-05:00xuqingkuangCustom model field for mysql time type.
2009-10-23T08:08:47.689832-05:00xuqingkuanghttps://djangosnippets.org/snippets/1769/<p>Django does not have a suitable model field can process time type in mysql, the DateTimeField built-in django can not process more than 24 hours. That's why the code born.</p>
<p><strong>Simply usage</strong>
`from myapp.models import TimeAsTimeDeltaField, SECONDS_PER_MIN, SECONDS_PER_HOUR, SECONDS_PER_DAY</p>
<p>class EstimatedTime:
days = None
hours = None
minutes = None …</p>
Freely redistributableSplit a string to a list and add to select options
2009-04-23T02:38:54.098332-05:00xuqingkuanghttps://djangosnippets.org/snippets/1461/<p>The template filter is use for split a string such as "foo|foobar|bar" to select option widget.
You can define the splitter of the string by yourself.</p>
<p><strong>Usage:</strong>
Add the code into templatetags folder of a installed app, then add below code into your template file.</p>
<p>`
{% load split_as_option %} …</p>
Freely redistributable