Skip to content

Instantly share code, notes, and snippets.



Created Jun 25, 2013
What would you like to do?
Extended QuerySelectField to allow SQLAlchemy objects to be passed in as default avalues
class QuerySelectFieldCustom(QuerySelectField):
"""Extended to allow default checked items
Probably a much more obvious way to do this...
selected = None
def iter_choices(self):
if self.allow_blank:
yield (u'__None', self.blank_text, is None)
for pk, obj in self._get_object_list():
if self.selected is not None and ==
yield (pk, self.get_label(obj), True)
yield (pk, self.get_label(obj), obj in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment