Created
August 26, 2013 18:42
-
-
Save andymccurdy/6344969 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TemplateWidget(object): | |
"Uses a template to render the widget" | |
def __init__(self, template, get_value_callable=None): | |
self.template = template | |
self.get_value_callable = get_value_callable | |
def __call__(self, field, **kwargs): | |
kwargs.update({'field': field}) | |
if self.get_value_callable: | |
kwargs['value'] = self.get_value_callable(field) | |
return render_to_string(self.template, kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment