djangosnippets.org: Latest snippets tagged with 'custom-field'http://djangosnippets.org/tags/custom-field/2011-05-30T21:00:23.741751-05:00A Django form field that accepts an uploaded image and creates a resized image attached with a push-pin
2011-05-30T21:00:23.741751-05:00rmisiohttp://djangosnippets.org/snippets/2449/<p>PushPinImageField is a Django form field that is a sub-class of an ImageField. The field accepts an image to upload and based on certain settings, notably the size of the resulting image, the sizes and colors of 3 different borders, as well as the color of the push pin, a …</p>
Freely redistributablemodels ColorField with clean minimal widget
2011-05-19T05:44:32.237425-05:00andybakhttp://djangosnippets.org/snippets/2441/<p>A simple model ColorField that allows picking from a predefined list (currently picked up from settings.py</p>
<p>The widget displays as a row of coloured SPAN's with the hex code inside. Simply click to choose a color.</p>
<p>(requires jQuery in the page assigned to it's normal $ shortcut. Easy to change …</p>
Freely redistributableTrueNoneField
2009-12-08T16:06:43.239323-06:00divermanhttp://djangosnippets.org/snippets/1831/<p>This custom model field is a variant of NullBooleanField, that stores only True and None (NULL) values. False is stored as NULL.</p>
<p>It's usefull for special purposes like unique/unique_together.</p>
<p>One small problem is here, that False is not lookuped as None.</p>
<p>This snippets is a response to <a href="http://www.djangosnippets.org/snippets/1830/">1830</a></p>
Freely redistributableCountryField (ISO 3166-1)
2009-04-29T05:17:54.011663-05:00dougalhttp://djangosnippets.org/snippets/1476/<p>List of countries based on the ISO 3166-1 standard.</p>
<p>List adapated from http://opencountrycodes.appspot.com/python/</p>
<p>This is useful for certain services such as Protx that requires countries in the two letter standard.</p>
Freely redistributableTuned IPAddressField with IPv4 & IPv6 support
2009-03-20T15:21:59.705446-05:00divermanhttp://djangosnippets.org/snippets/1381/<p>Tuned IPAddressField with IPv4 & IPv6 support</p>
Freely redistributableMAC address field
2009-02-23T15:59:50.794225-06:00divermanhttp://djangosnippets.org/snippets/1337/<p>Supported MAC formats:</p>
<p>aa:bb:cc:dd:ee:ff, separator : or -</p>
<p>aabbccddeeff</p>
<p>both lower case and upper case</p>
Freely redistributableCountryField (UN Country List, 3 Char Codes)
2009-01-12T08:11:07.686291-06:00djmhttp://djangosnippets.org/snippets/1281/<p><strong>Adapted from</strong> <a href="http://www.djangosnippets.org/snippets/494/">CountryField</a> - <strong>Initial thanks to marinho</strong></p>
<p>Uses the UN country list listed in the source - this provides the 3 character ISO country code.
Ordered by display value and not country code.</p>
<p>Just place anywhere you like and import CountryField to use.</p>
<p><code>country = CountryField(verbose_name="Country", help_text="The registrant's country …</code></p>
Freely redistributableEncryptField
2008-09-19T13:50:50.761889-05:00volksmanhttp://djangosnippets.org/snippets/1067/<p>I was trying to create a custom field to use the mysql encrypt() function on some data I wanted to store in the DB. initcrash on IRC pointed me to <a href="https://tracpub.yaco.es/cmsutils/browser/trunk/db/fields.py?rev=66">this code</a> which I butchered as best as my little brain could. Amazingly enough I got it working (thanks to …</p>
Freely redistributableMySQL "Text" Type Model Field
2008-05-27T16:33:45.612991-05:00blackbrrrhttp://djangosnippets.org/snippets/775/<p>Custom field for using MySQL's <code>text</code> type. </p>
<p><code>text</code> is more compact than the <code>longtext</code> field that Django assigns for <code>models.TextField</code> (2^16 vs. 2^32, respectively)</p>
Freely redistributable