Django template showing raw HTML instead of rendering

Hi

I am getting template showing raw HTML instead of rendering:

<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>

  <meta charset="utf-8">
  <title>{{title}}</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <!--style-->
  <style>
  .card {

   box-shadow: 0 4px 8px 0 rgba(0,0,0,0.5),
               0 6px 20px 0 rgba(0,0,0,0.39);
   background: lightpink;
   margin-bottom : 5%;
   border-radius: 25px;
   padding : 2%;
   overflow: auto;
   resize: both;
   text-overflow: ellipsis;
  }
  .card:hover{
    background: lightblue;
  }

  .submit_form{

    text-align: center;
    padding: 3%;
    background: pink;
    border-radius: 25px;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.4),
                0 6px 20px 0 rgba(0,0,0,0.36);
  }
  </style>

</head>

<body  class="container-fluid">

  {% if user.is_authenticated %}

  {% if messages %}
  {% for message in messages %}
  <div class="alert alert-info">
    <strong>{{message}}</strong>
  </div>
  {% endfor %}
  {% endif %}

  <center class="row">
    <h1><i>__TODO LIST__</i></h1>
    <hr />
  </center>

  <div class="row">

    <div class="col-md-8">

      {% for i in list %}
      <div class="card">
        <center><b>{{i.username}}</b></center>
        <hr/>
        <center><b>{{i.title}}</b></center>
        <hr/>
        {{i.date}}
        <hr/>
        {{i.details}}
        <br />
        <br />
        <form action="/del/{{i.id}}" method="POST" style=" padding-right: 4%; padding-bottom: 3%;">
          {% csrf_token %}
          <button value="remove" type="submit"  class="btn btn-primary" style="float: right;"><span class="glyphicon glyphicon-trash"></span> &nbsp; remove</button>
        </form>
      </div>
      {% endfor%}
    </div>
    <div class="col-md-1"> </div>
    <div class="col-md-3" >
      <div  class="submit_form">
      <form  method="POST">
        {% csrf_token %}
        {{ form_p }}
        <center>
        <input type="submit" class="btn btn-default" value="submit" />
      </center>
      </form>
    </div>
  </div>
</div>
</body>
{% else %}
<h3>Nothing to show!</h3>
{% endif %}
</html>

views.py:

from django.shortcuts import render,redirect
from django.contrib import messages
from django.contrib.auth import authenticate

## import todo form and models

from .forms import TodoForm
from .models import Todo

###############################################

def index(request):

    item_list = Todo.objects.order_by("-date")
    username = request.user
    if request.method == "POST":
        form = TodoForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('todo')
    form = TodoForm()
    page = {
             "forms" : form,
             "list" : item_list,
             "title" : "TODO LIST",
           }
    return render(request,'todo/index.html',page,username)


### function to remove item , it recive todo item id from url ##
def remove(request, item_id):
    item = Todo.objects.get(id=item_id)
    item.delete()
    messages.info(request,"item removed !!!")
    return redirect('todo')

models.py:

from django.db import models
from django.utils import timezone
from django.contrib.auth import get_user_model

# Create your models here.
class Todo(models.Model):
    username = models.CharField(max_length=50, null=False)
    title=models.CharField(max_length=100)
    details=models.TextField()
    date=models.DateTimeField(default=timezone.now)

    def __str__(self):
        return self.title

and forms.py:

from django import forms
from .models import Todo
from django.forms import ModelForm

class TodoForm(ModelForm):

    username = forms.CharField(max_length=50, widget = forms.TextInput(attrs={'class':'form-control'}))
    title = forms.CharField(max_length=50, widget = forms.TextInput(attrs={'class':'form-control'}))
    details = forms.CharField(max_length=1000, widget = forms.TextInput(attrs={'class':'form-control'}))
    date = forms.DateTimeField(widget = forms.DateTimeField())

    class Meta:
        model = Todo
        fields = ("username","title", "details", "date")

what is wrong in my code?

Your body closing tag needs to be put further down in your code (sorry,on mobile)

This is the part you have to move above the body closing tag
I think :thinking: (Im a noob. Sorry if derailing :grin:)

You’re passing an invalid parameter to your call to render. Review your parameters and the calling signature for that function at Django shortcut functions | Django documentation | Django

Right… And that too. Obviously! :grin::crazy_face::wink: