本文整理汇总了Python中models.Job.categories方法的典型用法代码示例。如果您正苦于以下问题:Python Job.categories方法的具体用法?Python Job.categories怎么用?Python Job.categories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Job
的用法示例。
在下文中一共展示了Job.categories方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_job
# 需要导入模块: from models import Job [as 别名]
# 或者: from models.Job import categories [as 别名]
def new_job():
if not g.site.domain == g.user:
abort(403)
j = Job()
if request.method == "POST":
portfolio = Portfolio.objects.get(site=g.site.domain)
job_name = request.form.get("name")
slugs = [__j.slug for __j in Job.objects.filter(site=g.site.domain)]
counter = 1
slug = slugify(job_name)
__slug = slug
while __slug in slugs:
counter += 1
__slug = "%s_%d" % (slug, counter)
j.slug = __slug
j.name = job_name
j.site = g.site.domain
j.categories = [ c.strip() for c in request.form.get("categories").split(",") ]
j.intro = request.form.get("intro")
j.description = request.form.get("description")
j.slides = []
texts = request.form.getlist("text")
image_urls = request.form.getlist("image_url")
captions = request.form.getlist("caption")
caption_links = request.form.getlist("caption_link")
for text, image_url, caption, caption_link in zip(texts, image_urls, captions, caption_links):
if text or image_url:
j.slides.append(Slide(text=text, image_url=image_url, caption=caption, caption_link=caption_link))
j.save()
portfolio.jobs.append(j)
portfolio.save()
return redirect(url_for(".job", slug=j.slug))
return render_template("edit_job.html", job=j)