I am trying to make a form with an input button group that redirects the user to another URL given the button they pushed. I am currently receiving a NoReverseMatch when I don't think I should be.
I went through the top answer of What is a NoReverseMatch error, and how do I fix it? but don't think those apply to me.
The form in index.html:
<form action="/main/community/" method="get">
<div class="btn-group" role="group" aria-label="Basic example">
<input type="button" class="btn btn-secondary" value='Comm1'>
<input type="button" class="btn btn-secondary" value='Comm2'>
<input type="button" class="btn btn-secondary" value='Comm3'>
</div>
</form>
My URL's:
app_name = 'main'
urlpatterns = [
path('', views.Index, name='index'),
path('community/', views.Community, name='community'),
path('community/choice',views.CommView, name='CommView'),
path('admin/', admin.site.urls)
]
My views:
def Community(request):
try:
pass
except (KeyError):
pass
else:
return HttpResponseRedirect(reverse('community/choice'))
def CommView(request):
return HttpResponse("Test success!.")
When I press the buttons no redirect occurs. When I manually input the URL of /community/choice/
I receive the following error:
NoReverseMatch
at /main/community/
Reverse for 'community/choice' not found. 'community/choice' is not a valid view function or pattern name.