Reputation: 37
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
})
new.html Error detected in this file by django
Could not parse the remainder
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.
Upvotes: 1
Views: 165
Reputation: 476574
A template tag is written between {%
and %}
, not
, so:{{ url 'new' owner_id }}
action="{% url 'new' owner_id %}"
Upvotes: 1