1👍
Your model looks correct to me. I see a couple of potential problems.
-
Depending on your templating engine, you might have to drop the parenthesis. I think Jinja2 uses them but Django Template Language does not. I think, based on the error message, you’re using the latter (DTL).
-
You probably just need to call the
all
method onproduto.categoria_set
. I’m pretty surecategoria_set
is a kind of manager object. You need a QuerySet, which will be returned when you callall
.
Here’s what you should try:
{% for categoria in produto.categoria_set.all %}
# SHOW ALL HERE. HOW?
{% endfor %}
Note: this answer is currently in flux because the original question contradicts itself.
Source:stackexchange.com