Django 1.2

I'm attempting to write my first custom Field Type. Eventually it will
do something more complicated, but for now I am simply sub-classing
the CharField. The first thing I'm doing is trying to change the
default form field to be a MultipleChoiceField.

I followed the directions here:
http://docs.djangoproject.com/en/dev/howto/custom-model-fields/#specifying-the-form-field-for-a-model-field

...but I keep getting a single select drop-down instead of a multiple
select.

Here's my custom field:
---------------------------------------------------------------------------------------------------------------------

class KevinsCharField(models.CharField):

    description = "Kevins char field"
    __metaclass__ = models.SubfieldBase

    def formfield(self, **kwargs):
        defaults = {'form_class' : forms.MultipleChoiceField}
        defaults.update(kwargs)
        return super(KevinsCharField, self).formfield(**defaults)

And here's where I define an instance of my field in a model
---------------------------------------------------------------------------------------------------------------------

    favorite_days = KevinsCharField(
        "My favorite days",
        max_length=200,
        choices=WEEKDAYS,
        blank=True)

Can anyone help me figure out what I'm missing?

Thanks,
Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to