Can’t pass a variable through my view to the html template

So I’m trying to: pass a variable owner_id in the view def new(request, owner_id) to render new.html that it will be used in the action of a form as a parameter/argument action="{{ url 'new' owner_id }}".

Like This:

def new(request, owner_id):  # from here
if request.method == 'POST':
    ...
else:
    category = Category.objects.all()
    render(request, "auctions/new.html", {
        "category": category,
        "owner_id": owner_id  # <--- to HERE
    })

view.py

urls.py

new.html Error detected in this file by django

Layout.html template

Could not parse the remainder

ERROR screenshot

It’s driving me crazy… I can’t understand why its not working.

And the worst part is I already did it on another view and it WORKED! The only difference is here I use the same variable again inside in the form to “feed” it again, throught the same url, view… etc. Whether there (another url and view) I used it as a normal variable inside the brakets {{ }}.

PD: I probably lack the basic understanding how django starts to process all this.

Answer

A template tag is written between {% and %}, not {{ url 'new' owner_id }}, so:

action="{% url 'new' owner_id %}"