我的views.py是
def editbook(request,book_id):
log.debug("test....")
if request.POST:
book_name =request.POST['book_name']
publisher_name =request.POST['publisher_name']
books=Book.objects.filter(book_id=book_id).update(book_name=book_name, publisher_name=publisher_name)
first_name = request.POST('first_name')
last_name = request.POST('last_name')
email = request.POST('email')
age = request.POST('age')
author_info = Author.objects.latest('author_id')
log.debug("test:%s",author_info.author_id)
author = Author.objects.filter(author_id=author_info.author_id).update(first_name = first_name,last_name = last_name,email=email,age=age)
return redirect('/index/')
else:
books = Book.objects.get(pk=book_id)
return render_to_response('editbook.html',{'books':books},{'author':author},context_instance=RequestContext(request))
我收到一个错误
"Traceback (most recent call last):
File "/usr/local/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/root/Samples/DemoApp/DemoApp/views.py", line 70, in editbook
return render_to_response('editbook.html',{'books':books},{'author':author},context_instance=RequestContext(request))
UnboundLocalError: local variable 'author' referenced before assignment.