showing the data in textarea for printing the items


here as shown in the above picture when i fill the fields (restau_name , veg_name, price, quantity) and click to save, the data should be shown in the below area and i should print the whole entries how i can do this ? please show me a path! thanks in advance

Have you worked your way through the Django Tutorial yet?

If not, that’s your best place to start. Because once you’ve completed it, you’ll have seen how to accept input from forms, how to save data in models, and how to display that data back on a page. You’ll have also created templates showing how do start doing layouts.

till now i have done this my views.py

from django.views.generic import ListView
from django.views.generic.edit import CreateView 
from .models import Bill

class HomePageView(ListView):
    model = Bill
    template_name = 'bill_list.html'

class NewBillPageView(CreateView):
    model = Bill
    fields = ['restau_name', 'veg_name', 'price', 'quantity']
    template_name = 'bill_new.html'
    success_url = '/'

my models.py are as below

from django.db import models
from django.conf import settings

class Bill(models.Model):
    restau_name = models.CharField(max_length=200)
    veg_name = models.CharField(max_length=200)
    price = models.IntegerField()
    quantity = models.IntegerField()
    date = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return (self.restau_name)

And here is my template as bill_list.html

{% extends 'base.html' %}
{% block title %}Bills{% endblock title %}
{% block content %}
 {% for bill in object_list %} 
 <div class="card"> 
 	<div class="card-header"> 
 		<span class="font-weight-bold">{{ bill.restau_name }}</span> &middot; 
 		<span class="text-muted">{{ bill.date }}</span> 
 	</div> 
 	<div class="card-body"> {{ bill.veg_name }} </div>	
 </div> 
	   <br /> 
	   <!-- <li>{{ bill }}</li> -->
 	{% endfor %} 
 {% endblock content %}

as you can see i have retreived the data from database.
Thanks for your reply

Great! Glad to see you’ve got it working.

Ken