本文整理匯總了Python中models.Build.url方法的典型用法代碼示例。如果您正苦於以下問題:Python Build.url方法的具體用法?Python Build.url怎麽用?Python Build.url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Build
的用法示例。
在下文中一共展示了Build.url方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_build
# 需要導入模塊: from models import Build [as 別名]
# 或者: from models.Build import url [as 別名]
def get_build(self):
""" Pre-fill some build attributes based on GET parameters """
build = Build(
forum_id = self.cleaned_data['forum_id'],
topic_id = self.cleaned_data['topic_id'],
user_id = self.request.user.id,
profile_id = self.request.user.get_profile().id,
title = self.cleaned_data['title'],
)
# create url
current_site = get_current_site(self.request)
build.url = "http://%s%s" % (current_site.domain, build.topic_url)
# Try to parse the scale
pattern = re.compile(r'1[:/](\d{1,4})')
match = re.search(pattern, build.title)
if match:
build.scale = match.group(1)
# see if we can match a brand...
bits = build.title.split()
for bit in bits:
brands = Brand.objects.filter(name__iexact=bit)
if brands:
build.brand = brands[0]
return build