本文整理汇总了Python中books.models.Book.author_name方法的典型用法代码示例。如果您正苦于以下问题:Python Book.author_name方法的具体用法?Python Book.author_name怎么用?Python Book.author_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类books.models.Book
的用法示例。
在下文中一共展示了Book.author_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
# 需要导入模块: from books.models import Book [as 别名]
# 或者: from books.models.Book import author_name [as 别名]
def add(request):
if request.method == 'GET':
form = BookAddForm()
else:
form = BookAddForm(request.POST)
if form.is_valid():
id_of_author=form.cleaned_data['author_id']
name_of_the_book = form.cleaned_data['name']
author_object = Author.objects.get(id=id_of_author)
book_object = Book()
book_object.name = name_of_the_book
book_object.author_name = author_object
book_object.save()
return HttpResponseRedirect('/landingpage/')
print author_object.name
return render(request, 'books/addbook.html', {'addbookform':form})