This file contains hidden or 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 import forms | |
from django.utils.safestring import mark_safe | |
from django.utils.encoding import force_unicode | |
class BootstrapRadioFieldRenderer(forms.RadioSelect.renderer): | |
def render(self): | |
"""Outputs a <ul> for this set of radio fields.""" | |
return mark_safe('<span id="id_%s"></span>' | |
'<ul class="inputs-list">\n%s\n</ul>' |
This file contains hidden or 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
def saves_only_changes(cls): | |
""" | |
When calling save(), only save changed model fields. | |
This is a class decorator, so use it thusly:: | |
@saves_only_changes | |
class Person(models.Model): | |
first_name = models.CharField(max_length=200) | |
last_name = models.CharField(max_length=200) |