Insert value in string template tag

Hello, I’m new to django and I’m facing the following issue:
i have the following code:

<form action="" method="post" enctype="multipart/form-data">
        {% for id, contact in form.items %}
        {{ contact.as_p }}
        <form action="{% url 'content_delete' id %}" method="post">
            <input type="submit" value="Delete">
            {% csrf_token %}
        </form>
        {% csrf_token %}
        {% endfor %}
        <p><input type="submit" value="Save content"></p>
</form>

I need to pass into “{% url ‘content_delete’ id %}” id but i cant and get error:

Reverse for 'content_delete' with arguments '('main',)' not found.

As I think the problem is that I’m passing it to a string and that’s why it doesn’t work but i dont know how to fix this. I would really appreciate any help

I don’t think the error is what you’re thinking it is.

What is your urls.py entry for the url named content_delete?

Side note: It appears in your template that you may be attempting to nest HTML form tags - that is not valid HTML.

What is your urls.py entry for the url named content_delete ?

    path('content/<int:id>/delete/',
         ContentDeleteView.as_view(),
         name='content_delete'),

and view

class ContentDeleteView(View):
    def post(self, request, id):
        content = get_object_or_404(Content,
                                    id=id,
                                    post_author=request.user)

        module = content.post
        content.item.delete()
        content.delete()
        return redirect('post_detail_change', module.id)

Side note: It appears in your template that you may be attempting to nest HTML form tags - that is not valid HTML

Hm…I need to add a delete button for each form. How do i make it better?

For the primary issue, I guess we’ll need to see the view that is generating the data.

In your template you have:

In this case, it appears that forms.items does not have the id field as the first element. We’ll need to see what forms is that you are rendering in the template.

A common solution (but not the only one) is to render an icon of a trash can with an anchor tag to the delete url.
Something to the effect of:
<a href="{% url 'delete_this' id %}"><img ...></a>

Omg, you are absolutely right. The problem was in my data… Such a dumb mistake, thanks for pointing me to that mistake