1
Based on your settings, you cannot play the file because:
{{ file.audio_file }}
returns value saved in the database, which is absolute path to media file, e.g.http://localhost:8000/Users/test/django_app/media/test.wav
To solve this, you need to:
-
Edit your
models.py
class AudioFile(models.Model):
audio_file = models.FileField(upload_to="music")upload_to — A path that will be appended to your MEDIA_ROOT setting to determine the value of the url attribute
-
In your template, use
{{ file.audio_file.url }}
to correctly reference the URL of the uploaded file -
You may need to delete existing files, because wrong path was saved in the database.
Source:stackexchange.com