[Answered ]-Django model data not appearing

1👍

First mistake – you are getting one Parasite object (cause you use method get) and you call it with plural name 'parasites':

parasite = Parasite.objects.get(slug=parasite_name_slug)
context_dict['parasites'] = parasite

Second mistake – when you want to show it in template, you call for single parasite, but you decided to name the key parasites.

{% for p in parasite %}

Third mistake – don’t use for loop for one object, just call it.

Answer:

views.py

parasite = Parasite.objects.get(slug=parasite_name_slug)
context_dict['parasite'] = parasite

viewpara.html

{% block content_block %}

    {{ parasite.name }}

{% endblock %}

Leave a comment