当前位置: 首页>>代码示例>>Python>>正文


Python Category.category_id方法代码示例

本文整理汇总了Python中models.Category.category_id方法的典型用法代码示例。如果您正苦于以下问题:Python Category.category_id方法的具体用法?Python Category.category_id怎么用?Python Category.category_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Category的用法示例。


在下文中一共展示了Category.category_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import category_id [as 别名]
 def post(self, username):
     user = self.authenticate()
     if user:
         supposed_category = request.get_json(force=True)
         category = Category()
         category.category_id = next_id(user)
         category.user_id = user.user_id
         category.name = supposed_category['name']
         category.icon = supposed_category['icon']
         db.session.add(category)
         db.session.commit()
         if category.category_id:
             return json.jsonify(category.as_dict())
     raise InvalidUsage()
开发者ID:felipemfp,项目名称:catherine,代码行数:16,代码来源:apis.py

示例2: fetch_categories

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import category_id [as 别名]
    def fetch_categories(self):
        """
        Fetch categories present on EventBrite.

        If categories are not cached into database, they are accessed from API and stored into database.
        Returns:

        """
        global categories_stored
        if not categories_stored:
            data = Category.objects.all().delete()
            payload = {"token": self.token}
            request = requests.get(self.base_url + "categories", params=payload)
            data = request.json()
            for category in data["categories"]:
                c = Category()
                c.name = category["name"]
                c.name_localized = category["name_localized"]
                c.category_id = category["id"]
                c.save()
            categories_stored = True

        data = Category.objects.all()
        return data
开发者ID:saurabhjinturkar,项目名称:eventbrite,代码行数:26,代码来源:EventBriteService.py

示例3: setUp

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import category_id [as 别名]
 def setUp(self):
     c = Category()
     c.name = 'test_category'
     c.category_id = 1
     c.save()
开发者ID:saurabhjinturkar,项目名称:eventbrite,代码行数:7,代码来源:tests.py


注:本文中的models.Category.category_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。