本文整理汇总了Python中models.Category.name_localized方法的典型用法代码示例。如果您正苦于以下问题:Python Category.name_localized方法的具体用法?Python Category.name_localized怎么用?Python Category.name_localized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Category
的用法示例。
在下文中一共展示了Category.name_localized方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fetch_categories
# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import name_localized [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