I have a django app with several form that I am trying to migrate to ajax. I am doing this because I want to update my data without refreshing my screen. I used the dajax library and started moving some of my views.py code into ajax.py.
I am getting a “ValueError: too many values to unpack ” in code that worked fine in views.py. I’m not sure why this is happening or how to fix it. Advice?
ajax.py
def send_student_form(request, form):
dajax = Dajax()
#error is here
student = Student.objects.get( form.get('student_id'))
#student = Student() # no ValueError, but it doesn't find my student.
if student:
print "Student Found!"
sForm = StudentProfileForm(request.POST, instance=student)
print student
else:
print "Student Not Found"
sForm = StudentProfileForm(request.POST)
#TODO: new Student
You need to define which field you are querying, for example:
Using non-keyword syntax is also allowed, but ugly. Non-keywords arguments are a special case in Django’s query building process, see constructor of the
Qclass if you want to know more.