The model field subclass returns string generated from the list of choices.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
class MultipleTypedChoiceModelField(models.Field):
    """
    Saving value of all the checked checkboxes in the string
    """    
    def get_internal_type(self):
        return 'MultipleTypedChoiceModelField'
    
    def get_prep_value(self, value):
        # In typical cases, you do not need to call additional methods,         
        # as incoming list already contains strings. 
        unicoded_val = [val.__unicode__() for val in value]
        return ', '.join(unicoded_val)

More like this

  1. ByteSplitterField by Lacour 1 year, 9 months ago
  2. Multiple Choice model field by danielroseman 4 years, 6 months ago
  3. MultiSelectField with comma separated values (Field + FormField) by quinode 1 year ago
  4. Choices datatype for model by menendez 5 years, 1 month ago
  5. Subclassing a model.field for newforms by chasfs 6 years, 1 month ago

Comments

zhikai (on November 30, 2011):

Welcome to our http://www.cauggboot.com online store. A variety of the latest ugg boots are stocked on our website.They are: http://www.australiauggshoe.com

#

(Forgotten your password?)