I'm trying to generate music with lilypond and render it to django template. When I try to run the script in cmd, midi file is generated but I can't render it to django template.
this works fine in cmd and generates music file which can be played -and rest of the code- :
views.py
-> lyout = subprocess.Popen(["lilypond", song_name])
out, err = lyout.communicate()
return render(request, "smcs/result.html", out)
this is my html template:
result.html page
{% for song in out %}
<audio controls preload="auto" id="audio" autoplay="autoplay">
<source src="../../{{ song }}" >
</audio>
{% endfor %}
- In result page i only see the file name but player is not shown. When i delete the {% for - end%} commands player is shown but song is not playing.
urls.py
urlpatterns = [......] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
settings.py
MEDIA_ROOT=os.path.join(BASE_DIR,"songdir")
MEDIA_URL='/media/'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
"django.template.context_processors.media",
'django.contrib.messages.context_processors.messages',
],
},
},
]
songs - urls.py
urlpatterns = [
url(r'^$', page),
url(r'^result/$', lygen) ]
lygen is my func name defined in views.py.
What am I doing wrong?? :(