本文整理汇总了Python中mkt.websites.models.Website.devices方法的典型用法代码示例。如果您正苦于以下问题:Python Website.devices方法的具体用法?Python Website.devices怎么用?Python Website.devices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.websites.models.Website
的用法示例。
在下文中一共展示了Website.devices方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fake_object
# 需要导入模块: from mkt.websites.models import Website [as 别名]
# 或者: from mkt.websites.models.Website import devices [as 别名]
def fake_object(self, data):
"""Create a fake instance of Website from ES data."""
obj = Website(id=data["id"])
# Set basic attributes on the fake instance using the data from ES.
self._attach_fields(obj, data, ("default_locale", "icon_hash", "mobile_url", "promo_img_hash", "tv_url", "url"))
# Set attributes with names that don't exactly match the one on the
# model.
obj.categories = data["category"]
obj.devices = data["device"]
obj.keywords_list = data["tags"]
if obj.icon_hash:
# If we have an icon_hash, then we have an icon. All the icons we
# store are PNGs.
obj.icon_type = "image/png"
# Attach translations for all translated attributes. obj.default_locale
# should be set first for this to work.
self._attach_translations(obj, data, ("description", "name", "short_name", "title"))
# Some methods might need the raw data from ES, put it on obj.
obj.es_data = data
return obj
示例2: fake_object
# 需要导入模块: from mkt.websites.models import Website [as 别名]
# 或者: from mkt.websites.models.Website import devices [as 别名]
def fake_object(self, data):
"""Create a fake instance of Website from ES data."""
obj = Website(id=data['id'])
# Set basic attributes on the fake instance using the data from ES.
self._attach_fields(obj, data, ('default_locale', 'icon_hash', 'url'))
# Set attributes with names that don't exactly match the one on the
# model.
obj.categories = data['category']
obj.devices = data['device']
if obj.icon_hash:
# If we have an icon_hash, then we have an icon. All the icons we
# store are PNGs.
obj.icon_type = 'image/png'
# Attach translations for all translated attributes. obj.default_locale
# should be set first for this to work.
self._attach_translations(
obj, data, ('description', 'name', 'short_name', 'title'))
# Some methods might need the raw data from ES, put it on obj.
obj.es_data = data
return obj
示例3: fake_object
# 需要导入模块: from mkt.websites.models import Website [as 别名]
# 或者: from mkt.websites.models.Website import devices [as 别名]
def fake_object(self, data):
"""Create a fake instance of Website from ES data."""
obj = Website(id=data['id'])
# Set base attributes on the fake instance using the data from ES.
self._attach_fields(obj, data, ('default_locale',))
# Set attributes with names that don't exactly match the one on the
# model.
obj.categories = data['category']
obj.devices = data['device']
# Attach translations for all translated attributes. obj.default_locale
# should be set first for this to work.
self._attach_translations(
obj, data, ('url', 'description', 'short_title', 'title'))
# Some methods might need the raw data from ES, put it on obj.
obj.es_data = data
return obj