I'm trying to write a custom select widget for a modelform field, but
the render method of the widget doesn't seem to get called.

This is how I define the modelform:

class MyForm(ModelForm):
    class Meta:
        model=MyModel
        fields=('data',)
        widgets = {
            'data': MySelect(),
        }

This is my MySelect:

class MySelect(Select):
    def __init__(self, attrs=None, choices=()):
        print "in init"
        super(MySelect, self).__init__(attrs)
        self.choices = list(choices)
        print "leaving init"

    def render(self, name, value, attrs=None, choices=()):
         print "entering render"
         return mark_safe("<h1>Yuhuu</h1>")

The debug in __init__ gets called ok, but not in render. I have also
tried to subclass widget, but without any luck. I'm guessing there is
an error in how I define the widget. Any Ideas what might be wrong?

Thanks.

-- 
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