本文整理汇总了Python中models.Author.category方法的典型用法代码示例。如果您正苦于以下问题:Python Author.category方法的具体用法?Python Author.category怎么用?Python Author.category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Author
的用法示例。
在下文中一共展示了Author.category方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: authors
# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import category [as 别名]
def authors(request):
verses = Verse.category().instance.all()
authors = Author.category().instance.all()
years = Year.category().instance.all()
if request.method == 'GET':
return render(request, 'jinja2/index.html', {'verses': verses,
'authors': authors,
'years': years})
elif request.method == 'POST':
if request.POST.get('author_name'):
Author(name=unicode(request.POST['author_name'])).save()
authors = Author.category().instance.all()
return render(request, 'jinja2/index.html', {'verses': verses,
'authors': authors,
'years': years})
示例2: names
# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import category [as 别名]
def names(request):
verses = Verse.category().instance.all()
authors = Author.category().instance.all()
years = Year.category().instance.all()
auth_names = [author.name for author in Author.category().instance.all()]
year_list = [year.year for year in Year.category().instance.all()]
if request.method == 'GET':
return render(request, 'jinja2/names.html', {'verses': verses,
'authors': authors,
'years': years})
elif request.method == 'POST':
if request.POST.get('name') and request.POST.get('text'):
verse = Verse(
name=unicode(request.POST['name']), text=unicode(request.POST['text'])).save()
if request.POST.get('author'):
if unicode(request.POST.get('author')) in auth_names:
verse.author.connect(
Author.index.get(name=request.POST['author']))
else:
Author(name=unicode(request.POST['author'])).save()
verse.author.connect(
Author.index.get(name=unicode(request.POST['author'])))
if request.POST.get('year'):
if int(request.POST.get('year')) in year_list:
verse.year.connect(
Year.index.get(year=int(request.POST['year'])))
else:
Year(year=request.POST['year']).save()
verse.year.connect(
Year.index.get(year=int(request.POST['year'])))
verses = Verse.category().instance.all()
authors = Author.category().instance.all()
years = Year.category().instance.all()
return render(request, 'jinja2/names.html', {'verses': verses,
'authors': authors,
'years': years})
示例3: years
# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import category [as 别名]
def years(request):
verses = Verse.category().instance.all()
authors = Author.category().instance.all()
years = Year.category().instance.all()
if request.method == 'GET':
years = Year.category().instance.all()
return render(request, 'jinja2/years.html', {'verses': verses,
'authors': authors,
'years': years})
elif request.method == 'POST':
if request.POST.get('year') is not None:
Year(year=unicode(request.POST['year'])).save()
years = Year.category().instance.all()
return render(request, 'jinja2/years.html', {'verses': verses,
'authors': authors,
'years': years})