本文整理汇总了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()
示例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
示例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()