本文整理匯總了Python中models.Site.name方法的典型用法代碼示例。如果您正苦於以下問題:Python Site.name方法的具體用法?Python Site.name怎麽用?Python Site.name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Site
的用法示例。
在下文中一共展示了Site.name方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: sites
# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import name [as 別名]
def sites():
root_domain = app.config.get("DOMAIN_ROOT")
port = app.config.get("PORT", None)
if request.method == "POST":
domain = request.form["domain"]
name = request.form["name"]
if domain and name:
site = Site()
site.name = name.strip()
site.domain = domain.strip()
conflicting_site = Site.objects.filter(domain=site.domain).first()
if not conflicting_site:
site.description = _(
"<h1>Introductory text</h1><p>This should "
"contain simple help about what is changeable and how."
"</p>"
)
site.save()
url = "//%s" % site.domain
if root_domain:
url += ".%s" % root_domain
if port:
url += ":%d" % port
return redirect(url)
return redirect(url_for("sites"))
if root_domain == g.site.domain:
sites = Site.objects.all()
else:
sites = Site.objects.filter(domain__endswith=g.site.domain)
return render_template("sites.html", sites=sites, root_domain=root_domain, port=port)
示例2: _tx
# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import name [as 別名]
def _tx():
site = Site.get_by_key_name(loc["id"])
if site is None:
site = Site(key_name=loc["id"])
site.location = GeoPt(lat = loc["location"][0], lon = loc["location"][1])
site.name = loc["name"]
site.region = loc["region"]
site.save()
示例3: get_site
# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import name [as 別名]
def get_site():
try:
site = Site.objects.get(name=EbaySpider.name)
except DoesNotExist as e:
logging.info(">>>> Creating site")
site = Site()
site.name = EbaySpider.name
return site