当前位置: 首页>>代码示例>>Python>>正文


Python Author.category方法代码示例

本文整理汇总了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})
开发者ID:Isizukuri,项目名称:livaravaTest,代码行数:17,代码来源:views.py

示例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})
开发者ID:Isizukuri,项目名称:livaravaTest,代码行数:38,代码来源:views.py

示例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})
开发者ID:Isizukuri,项目名称:livaravaTest,代码行数:18,代码来源:views.py


注:本文中的models.Author.category方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。