I cannot send a variable to template in django

Viewed 80

I am trying to send data to a template but it doesn't get rendered. The html file loads but the field {{patient}} is blank and doesn't show 'abcde'.

Here is my code:

views.py

def exam_table(request):
    context = {'patient': 'abcde'}
    return render(request, 'examtable.html', context)

examtable.html

<div class="row d-flex align-items-center">
   <div class="col-9">
   <h3 class="f-w-300 d-flex align-items-center m-b-0">
   <i class="feather icon-arrow-up text-c-green f-30 m-r-10"></i>$
   <p>{{patient}}</p></h3>
   </div>

urls.py

urlpatterns = [
    # The home page
    path('', views.index, name='home'),
    path('insert_patient',views.insert_patient,name='insert_patient'),
    path('nurse_patient',views.nurse_patient,name='nurse_patient'),
    path('examtable',views.exam_table,name='examtable'),     


    # Matches any html file
    re_path(r'^.*\.*', views.pages, name='pages'),
]
1 Answers

it should pass a dictionary value

def exam_table(request):
    context = {'patient': 'abcde'}
    return render(request, 'yourpage.html', {'context': context})
Related