def index(): """ Get categories. rtype: dict """ db_categories = Category.all() categories = list() for x in db_categories: categories.append({ 'id': x.hash_id, 'name': x.name, 'url_safe_name': "_".join(x.name.split(' ')) }) return categories
def data(self): return { 'name': self.fake.name(), 'description': ' '.join(self.fake.paragraphs(nb=10)), 'category_id': random.choice(Category.all()).id }