Reputation: 31
When I open the django app and view the site check is visible but nothing from my model is printed I want to display the data that I have stored in the customers model in the html file
from django.db import models
# Create your models here.
class Customer(models.Model):
name = models.CharField(max_length=1000)
Status =models.CharField(max_length=1000,blank=True, null=True)
def __str__(self):
return self.name
from django.shortcuts import render
from django.template.response import TemplateResponse
from Core.models import Customer
def user_profile(request):
data = Customer.objects.all()
return render_to_response(request,"templates/home.html", {"data": data})
{% extends 'base.html' %}
{% block title %}Video Page
{% endblock %}
{% block content %}
{% for customer in data %}
<h1> {{ customer.name}}</h1>
{% endfor %}
<h1>check</h1>
{% endblock %}
Upvotes: 0
Views: 77
Reputation: 143
use render instead of render_to_response
def user_profile(request):
data = Customer.objects.all()
return render(request,"templates/home.html", {"data": data})
Upvotes: 1