Created
January 16, 2013 23:13
-
-
Save bulkan/4551910 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
from django.template import loader, Context | |
from django.utils.safestring import mark_safe | |
class MyWidget(forms.RadioSelect.renderer): | |
def render(self): | |
'''Outputs radios''' | |
t = loader.get_template('my_widget.html') | |
c = Context({"radios": self, | |
"name": self.name}) | |
return mark_safe(t.render(c)) | |
# my_widget.html | |
<div id="div-{{name}}"> | |
{% for r in radios %} | |
<span id="span-id-{{name}}-{{forloop.counter0}}"> {{ r }}</span> | |
{% endfor %} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment