data are not send from view to templeate

  django, python

fapp/views.py

from django.shortcuts import render
from django.http import HttpResponse
from . models import dhiraj

def index(request):
t=dhiraj.objects.all()
context={'dhiraj':t}
return render(request,'fapp/index.html',context)

def __str__(self):
    return self.title

indext.html

<h1>this is</h1>

{% for taskk in dhiraj %}
<div>
<p>{{taskk}}</p>
</div>
{% endfor %}

models.py

from django.db import models

class dhiraj(models.Model):
title=models.CharField(max_length=200, default="" )
completed=models.BooleanField(default=False)
created_at=models.DateTimeField(auto_now=True)

output is
this is
other outputs are not shown

Source: Python Questions

LEAVE A COMMENT