I’m sure I’m not understanding render() and redirect() correctly, but why does this:
return render(request, 'catalog/add.html', {'form': form})
(where the app name is ‘catalog’)
Produce this url:
http://127.0.0.1:8000/catalog/add/catalog_add
This happens with this function:
def catalog_add(request):
if request.method == 'POST':
form = ArtworkForm(request.POST)
if form.is_valid():
form.save()
return redirect('catalog')
else:
form = ArtworkForm()
return render(request, 'catalog/add.html', {'form': form})
The GET finds the html page (catalog/add.html) and correctly populates it with an empty form, but the POST results in ‘Page not found… The current path, catalog/add/catalog_add, didn’t match any of these.’
Both render() and redirect() have the same behavior.