Record user's voice and save it to db in Django

605 Views Asked by At

I want to build a Django app in which a user can record his/her voice. I have used the following link: https://github.com/Stephino/stephino.github.io/blob/master/tutorials/B3wWIsNHPk4/index.html in order to capture user's voice and it works perfectly for me, but I do not know exactly how to save it to database. I do not know how to build my Model and also a form to do this. Does anybody have any idea? (The obligatory framework is Django and in terms of db my preference is Postgresql)

1

There are 1 best solutions below

2
On

I think storing an audio file in a Database is not a feasible solution. You should consider using Django FileField Instead.

Refer to the documentation here: https://docs.djangoproject.com/en/3.2/ref/models/fields/#django.db.models.FileField

# file will be saved to MEDIA_ROOT/uploads/2021/05/27
upload = models.FileField(upload_to='uploads/%Y/%m/%d/')