def __init__(self, *args, **kwargs): super(EntryForm, self).__init__(*args, **kwargs) categories = category_service.get_all_categories() self.category.choices = [(cat.key.urlsafe(), cat.category) for cat in categories] tags = tag_service.get_all_tags() self.tags.choices = [(tag.key.urlsafe(), tag.tag) for tag in tags]
def get(): tags = service.get_all_tags() view = [TagView(tag).__dict__ for tag in tags] sorted_view = sorted(view, key=lambda t: t['category']) return Response(json.dumps(sorted_view), 200, mimetype='application/json')