Also forgot to mention that from the shell, I can easily go:

sw = StarboxWidget()
sw.render(name='test')

and it outputs a html string like I'd expect.

On Feb 16, 1:13 am, Zack <[EMAIL PROTECTED]> wrote:
> So,
>
> I'd like to make a custom widget based on starbox 
> (http://www.nickstakenburg.com/projects/starbox/). Basing this on the TinyMCE
> example, but I am having some major difficulties rendering it. Namely
> getting my TEMPLATE_STRING_IF_INVALID on the form when trying to
> render it.
>
> 1) Is there a good way to debug this?
> 2) Here's the field in my form:
> rating = forms.CharField(widget=StarboxWidget())
> 3) Here's my widget class:
>
> class StarboxWidget(Textarea):
>
>     starbox_settings = dict(
>         stars = 10,
>         buttons = 10,
>         max = 10,
>         total = 0,
>         rerate = 'true',
>         color = '#FBB917',
>     )
>
>     def update_settings(self, custom):
>         return_dict = self.starbox_settings.copy()
>         return_dict.update(custom)
>         return return_dict
>
>     def render(self, name, attrs=None):
>         final_attrs = self.build_attrs(attrs, name=name)
>         self.starbox_settings['elements'] = "id_%s" % name
>         starbox_json =
> JSONEncoder().encode(self.starbox_settings)
>         return u'<div id="%s"></div><script type="text/javascript">\
>                     new Starbox("%s", 0, %s);</script>' % (name, name,
> starbox_json)
>
> 4) Is there any documentation on specifically for custom widgets, when
> render gets called, etc?
>
> Thanks for any direction someone could provide.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to