3👍
✅
This is because you insert it twice. The .create(…)
method [Django-doc] already inserts in in the database. So you can implement this as:
def display(request):
print('display functio')
d=upload.objects.last()
test=sr.takeCommand(d.file.path)
# will store the record in the database
p = text.objects.create(texts=test)
print(test)
return render(request,'thanks.html',{'print':test})
you can link it to d
with:
def display(request):
print('display functio')
d=upload.objects.last()
test=sr.takeCommand(d.file.path)
# will store the record in the database
p = text.objects.create(texts=test, upload_text=d)
print(test)
return render(request,'thanks.html',{'print':test})
Note: Models in Django are written in PerlCase, not
snake_case, so you might want to rename the model fromtotext
Text
.
Source:stackexchange.com