我在尝试提交表单时遇到以下错误?
var url = 'http://omcloud.azurewebsite.net/api/Test';
request.post(url,
{ json: { "Definition": "Test"} },
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body)
}
}
);
以下是我的File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
IntegrityError: NOT NULL constraint failed: courses_query.course_id
观点:
query_create
以下是我的查询模型:
def query_create(request, course_pk,step_pk): #what course this quiz belongs to
text = get_object_or_404(models.Text, course_id=course_pk, pk=step_pk)
form = forms.QueryForm() #create blank form
if request.method == 'POST':
logging.error('Inside Post.....................................................................')
form = forms.QueryForm(request.POST)
if form.is_valid():
query = form.save(commit=False) #dont put anything in daabase make model quiz instance
#query.course = course
query.text = text
query.save()
messages.add_message(request, messages.SUCCESS,
"Quiz Added!")
return HttpResponseRedirect(query.get_absolute_url())
return render (request,'courses/query_form.html', {'form':form , 'text': text})