'Resolving Delete event failure in Django

This is error I have been trying to solve for last 7 days. I am a newbie to Django

Page not found (404)
Request Method:     POST
Request URL:    http://localhost:8000/projects/delete-project/ce4c5177-eb8f-44b9-9734-04adafd75414/ 

 Using the URLconf defined in devsearch.urls, Django tried these URL patterns, in this order:

    admin/
    projects/ projects/ [name='projects']
    projects/ project/<str:pk>/ [name='project']
    projects/ create-project/ [name='create-project']
    projects/ update-project/<str:pk>/ [name='update-project']
    projects/ delete-project/<str:pk>/ [name='delete-project']

This message appears after clicking the submit button on my delete-object form which correctly refers to the object being deleted name attribute...which in my mind means the object has been found in the database and is being correctly referenced.

Here is the Code:

url.py of the application

    from django.urls import URLPattern, path
    from . import views

urlpatterns = [
    path('projects/', views.projects, name='projects'),
    path('project/<str:pk>/', views.project, name='project'),
    path('create-project/', views.createProject, name='create-project'),
    path('update-project/<str:pk>/',
         views.updateProject,
         name='update-project'),
    path('delete-project/<str:pk>/',
         views.deleteProject,
         name='delete-project'),
]

View Function Code:

@login_required(login_url='login')
def deleteProject(request, pk):
    profile = request.user.profile
    project = Project.objects.get(id=pk)
    if request.method == 'POST':
        project.delete()
        return redirect('account')
    context = {'object': project}
    return render(request, 'delete-object.html', context)

Confirmation HTML Page

<form class="form" method="POST" action="'">
                {% csrf_token %}
                <p>Confirm deletion of '{{object}}'</p>    
                <button class="btn btn--sub btn--lg  my-md"><a href="{{request.GET.next}}">Go Back</a></button>    
                <a href="delete-object" ><Input class="btn btn--sub btn--lg  my-md" type='submit' value='DELETE' style="color: red;" /></a>
            </form>

Create, Read, and Update events work correctly. its just the delete event. I tried asking this question on Django community and was told to read the Django help docs :( I don't see what I am missing. Hoping someone can provide some insight.

Thanks for looking.



Solution 1:[1]

You need replace:

<button class="btn btn--sub btn--lg my-md"><a href="{{request.GET.next}}">Go Back</a></button>

To

<button class="btn btn--sub btn--lg my-md">Go Back</button>

Because link conflicted with button.

Try form as:

<form class="form" method="POST" action="">
                {% csrf_token %}
                <p>Confirm deletion of '{{object}}'</p>    
                <button class="btn btn--sub btn--lg  my-md">Go Back</button>    
                <Input class="btn btn--sub btn--lg  my-md" type='submit' value='DELETE' style="color: red;" />
            </form>```

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 crazyzubr