Skip to content
Advertisement

Browser Output of HTML/Django/Python shows nothing of Python code

I am following Mosh course (Python for beginner (6 hrs)). In the Django project, When listing the products from the database with HTML/Python/Django code. The output not showing it correctly. In fact, it shows blank after the h1 tag.

View module code.

JavaScript

HTML Code.

JavaScript

The output just show heading Products

Advertisement

Answer

you have a typo. In the context data you provide to your template you are using the key ‘product’ for your queryset:

JavaScript

In the template you are referencing ‘products’ which is not defined.

JavaScript

Update the name for your queryset to products: {‘products’: products}

Recommend installing the django debug toolbar. You can view the context passed to the template.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement