예제 #1
0
파일: views.py 프로젝트: silves-xiang/book
def add_book(request):
    if request.method == 'POST':
        new_book = Book(
            name=request.POST.get('name', ''),
            author=request.POST.get('author', ''),
            category=request.POST.get('category', ''),
            price=request.POST.get('price', ''),
            publish_date=request.POST.get('publish_date'),
            create_datetime=request.POST.get('create_datetime'),
        )
        new_book.create_datetime = time.strftime('%Y%m%d%H%I')
        new_book.save()
        return HttpResponseRedirect(reverse('management:index'))
    return render(request, 'management/add_book.html')