[Fixed]-Issue with django rendering data onto template

0๐Ÿ‘

โœ…

Try to remove menuitems from view (or just donโ€™t add menuitems to context) and replace {% for item in menuitems %} with {% for item in menu.menuitem_set.all %}.

๐Ÿ‘คf43d65

1๐Ÿ‘

{% for item in menuitems %}
     <p>Item {{ item.item_name }}</p>
     <p>Description {{ item.description }}</p>
     <p>$ {{ item.price }}</p>
{% endfor %}

Change this code to ,

{% for item in menu.menuitem.all %}
   <p>Item {{ item.item_name }}</p>
   <p>Description {{ item.description }}</p>
   <p>$ {{ item.price }}</p>
{% endfor %}
๐Ÿ‘คGeo Jacob

0๐Ÿ‘

As @Geo Jacob has suggested, made those changes. Also in the view function, no need to set โ€œmenuitemsโ€ variable in the context dictionary.

Leave a comment