def save_book_from_row(book_row): book = Book() book.id = book_row[0] book.title = book_row[1] # book.category=book_row[2] book.author = book_row[3] book.publication = book_row[4] book.category = book_row[5] book.save()
def create_book(request): if request.method == 'POST': createbookform = CreateBookForm(request.POST, request.FILES) if createbookform.is_valid(): book = Book() book.category = createbookform.cleaned_data['category'] book.name = createbookform.cleaned_data['name'] book.cover = createbookform.cleaned_data['cover'] book.summary = createbookform.cleaned_data['summary'] book.author = request.user.author book.save() return redirect(reverse('author:update_book', args=[book.pk])) else: print(createbookform.errors) else: createbookform = CreateBookForm() context = dict() context['createbookform'] = createbookform return render(request, 'author_area/manage/create_book.html', context)