Login

Tag "custom-field"

Snippet List

A Django form field that accepts an uploaded image and creates a resized image attached with a push-pin

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 re-sized image is created with a colorized push pin in the top-center. A live demo of the field as well as more detailed usage instructions are available as a [blog entry](http://www.robmisio.com/blog/2/).

  • django
  • image
  • thumbnail
  • form
  • field
  • custom-field
Read More

models ColorField with clean minimal widget

A simple model ColorField that allows picking from a predefined list (currently picked up from settings.py The widget displays as a row of coloured SPAN's with the hex code inside. Simply click to choose a color. (requires jQuery in the page assigned to it's normal $ shortcut. Easy to change this is you don't use jQuery in this way)

  • models
  • admin
  • jquery
  • widget
  • custom-field
  • modelfield
Read More

TrueNoneField

This custom model field is a variant of NullBooleanField, that stores only True and None (NULL) values. False is stored as NULL. It's usefull for special purposes like unique/unique_together. One small problem is here, that False is not lookuped as None. This snippets is a response to [1830](http://www.djangosnippets.org/snippets/1830/)

  • null
  • field
  • custom-field
  • none
Read More

CountryField (ISO 3166-1)

List of countries based on the ISO 3166-1 standard. List adapated from http://opencountrycodes.appspot.com/python/ This is useful for certain services such as Protx that requires countries in the two letter standard.

  • field
  • country
  • custom-field
  • iso-3166-1
  • protx
Read More

MAC address field

Supported MAC formats: aa:bb:cc:dd:ee:ff, separator : or - aabbccddeeff both lower case and upper case

  • model
  • field
  • custom-field
  • address
  • mac
Read More

CountryField (UN Country List, 3 Char Codes)

**Adapted from** [CountryField](http://www.djangosnippets.org/snippets/494/) - **Initial thanks to marinho** 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. Just place anywhere you like and import CountryField to use. `country = CountryField(verbose_name="Country", help_text="The registrant's country of residence.")`

  • forms
  • form
  • field
  • list
  • country
  • countries
  • custom
  • custom-field
  • countryfield
  • countrys
Read More
Author: djm
  • 1
  • 1

EncryptField

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 [this code](https://tracpub.yaco.es/cmsutils/browser/trunk/db/fields.py?rev=66) which I butchered as best as my little brain could. Amazingly enough I got it working (thanks to a couple answers from initcrash). If anyone can clean this up that would be great. I'm also trying to figure out how I can a) create password reset link in the admin interface for this field without displaying the field or b) decrypt it so that the password field is pre-populated with the decrypted password. Otherwise it is submitting the encrypted string as a new password. Anyways, I'm only a week or two into Django with no python experience so any suggestions are very welcome. Hope this helps someone!

  • mysql
  • crypt
  • custom-field
  • encrypt()
Read More

MySQL "Text" Type Model Field

Custom field for using MySQL's `text` type. `text` is more compact than the `longtext` field that Django assigns for `models.TextField` (2^16 vs. 2^32, respectively)

  • text
  • models
  • mysql
  • db
  • database
  • field
  • custom-field
Read More

9 snippets posted so far.