Django return sends me to index.html everytime I hit submit

Hey,

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)

Thanks for your help!

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.

No it’s just here at this form,

this is my url for the view:

    path('linkshortener/', views.view_linkshortener, name="linkshortener"),

So you have other forms being submitted from other views that are working as expected?

yes thats correct, other forms are working as expected

How are you running this? Is this while running this under runserver, or in some other environment?

its running under runserver

Is there any JavaScript on that page? (Anything that might be listening to button clicks?)

Also, does your submit button have an action associated with it?

found the error, I made an "action=“index.html” in my form. Stupid me.

Thanks for your help