I have a view with a form and its very weird, everytime I hit submit django adds /index.html to my url and sends me to that. Oviously the new url doesnt exist. I guess it has something to do with the render because its the only thing which gets triggered when I hit submit.
This is my view:
def view_linkshortener(request):
token = uuid.uuid4()
form = LinkForm()
if request.method == 'POST':
form = LinkForm(request.POST)
if form.is_valid():
linktemp = form.save(commit=False)
linktemp.user = request.user
linktemp.uid = token
linktemp.save()
context = {'form': form, 'token': token}
return render(request, 'home/linkshortener.html', context)
Is it only this form, or does it occur elsewhere on your site?
What url is mapped to this view?
You’re not returning a redirect here, so it’s possible (likely, even) that this is happening because of something else in your environment or configuration.