Return values in ForeignKey and ManyToManyField in Django

0

I have the following Models: Restaurant with a ForeignKey for Cardapio, Cardapio with a ManyToMany for Product, Product with a ManyToMany for DiaPromocao, and I need in the template to display some information such as restaurant, product, price and the promotional price of the product. The restaurant and the product I can show, through a method that returns the product names in the Cardapio model, but the other information with the normal price and promotional price of the product I can not, can someone help me here?

Follow the gist link with the templates: link

    
asked by anonymous 22.05.2015 / 13:51

1 answer

0

I do not think it's a good idea to format the list of products and prices in the model, you can do this directly in the template.

In the template it would look something like this:

{% for produto in cardapio.produtos.all %}
    {{ produto }} {{ produto.preco_promocao }}
{% endfor %}
    
22.05.2015 / 21:05