djangosnippets.org: Latest snippets posted by Lacourhttp://djangosnippets.org/users/Lacour/2011-08-24T17:18:17.166457-05:00LacourByteSplitterField
2011-08-24T17:18:17.166457-05:00Lacourhttp://djangosnippets.org/snippets/2528/<p>When you want to save integers to the db, you usually have the choice between 16-, 32- and 64-bit Integers (also 8- and 24-bit for MySQL). If that doesn't fit your needs and you want to use your db-memory more efficient, this field might be handy to you.
Imagine you …</p>
Freely redistributableTinyIntegerField
2011-08-15T17:39:42.478692-05:00Lacourhttp://djangosnippets.org/snippets/2513/<p>Django lacks support of MySQL's "tinyint" 8-bit-integer datatype. This snippet gives you a TinyIntegerField and a PositiveTinyIntegerField. Falls back Django's SmallIntegerField if a different database-engine is used</p>
Freely redistributableDynamically add css-classes to formfields
2011-07-13T17:06:25.685091-05:00Lacourhttp://djangosnippets.org/snippets/2487/<p>This example assumes you have a form and want to highlight one of two fields
by setting <class="highlight"> in the html dynamically. This is an alternative to
<a href="https://docs.djangoproject.com/en/1.3/ref/forms/widgets/#customizing-widget-instances">https://docs.djangoproject.com/en/1.3/ref/forms/widgets/#customizing-widget-instances</a>,
but now you're not limited to assigning the class to the fields html-output,
instead you can also assign it to a …</p>
Freely redistributableCheckbox or radio iterator as template filter
2010-08-22T07:57:41.475794-05:00Lacourhttp://djangosnippets.org/snippets/2159/<p>This snippet is based on <a href="http://djangosnippets.org/snippets/2151/">Bill Freeman's MultiSelect checkbox iterator template filter</a>.</p>
<p>Usage: See docstring</p>
Freely redistributableForm and FormSet that are defined dynamically with request-data
2010-01-10T05:26:09.140543-06:00Lacourhttp://djangosnippets.org/snippets/1863/<p>This is how you can access the user's request in the Form or FormSet definition, e.g. to define the choices of a ChoiceField dynamically.
Either you use it for a single Form or a whole FormSet, just pass the view's request into the Form or FormSet instantiation.</p>
Freely redistributable