I am trying to create a simple form where user can insert information. If user click send button, information will be displayed.
Here is the code in views.py.
from kay.utils import render_to_response
from myapp.form import ContactForm
from myapp.models import NhanThu
# Create your views here.
@login_required
def index(request):
form_test = ContactForm()
if request.method =="POST" and form_test.validate(request.form):
NhanthuModelbien = NhanThu(subject=ContactForm['subject'])
NhanthuModelbien.put()
return redirect(url_for('myapp/index'))
query = NhanthuModelbien.all().order('-created')
inthuwhat = query.fetch(20)
return render_to_response('myapp/index.html',
{'form2': form_test.as_widget(),'inthura': inthuwhat})
I always receive this errorr "UnboundLocalError: local variable 'NhanthuModelbien' referenced before assignment". Can anybody point out what is wrong here?