NoReverseMatch : Reverse for 'download' not found. 'download' is not a valid view function or pattern name.
2021. 4. 10. 21:00ㆍ파이썬/Django
/mp3/views.py
def index(request) :
template = 'index.html'
return render(request, template, None)
mp3/templates/index.html
<input type="text" size="50" value="">
<input type="button" value="다운로드" onclick="location.href='{% url 'mp3:download' %}'">
mp3/urls.py
app_name = 'mp3'
urlpatterns = [
path('', views.index, name='index'),
]
index.html에서 찾는 download가 없기 대문에 에러 발생
아래와 같이 추가해줘야 함
views.py
def index(request) :
template = 'index.html'
return render(request, template, None)
def download(request) :
return HttpResponseRedirect(reverse('mp3:index'))
urls.py
app_name = 'mp3'
urlpatterns = [
path('', views.index, name='index'),
path('download/', views.download, name='download'),
]
'파이썬 > Django' 카테고리의 다른 글
pytube.exceptions.RegexMatchError: get_ytplayer_config: could not find match for config_patterns (0) | 2021.04.10 |
---|---|
Forbidden (403) : CSRF verification failed. Request aborted. (0) | 2021.04.10 |
The current path, mp3/, didn't match any of these. (0) | 2021.04.06 |
Django urls.py 셋팅 (0) | 2021.04.06 |
Django project 생성 (0) | 2021.04.06 |