How to create a table which is connected with Model.

I want to create a table with the input fields included and doing some calculations inside the table taking out sum of columns and multiply columns. Can anyone guide me on how can I get that result?
Something like this:

hello, you can calculate data by writing the save method of your model and store the result in another field or model. but if you want it to be in real time the calculation has to be with javascript or jquery.

I hope this helps you:

The table structure you will have to create in your template or in the front end.

If you’re using “pure” Django (and not react, Vue etc as the front end), then what you probably want to look at is formsets.

https://docs.djangoproject.com/en/3.2/topics/forms/formsets/

In particular for your case, you will likely want inlineformset_factory()

https://docs.djangoproject.com/en/3.2/ref/forms/models/#inlineformset-factory

As far as the totals are concerned, when you change the data you will have to update this with javascript - either that or resubmit the form every time and refresh the page, which is perhaps not the most performant option.

Thanks for the reply. Now I have another question:
How am I suppose to use forms when I have already TemplateView and want that forms to be inside that same TemplateView?

You just put a form into your template. Since you’re not using any kind of model view, you can’t handle it automatically, so you’ll need to populate the context with the data you want, but this seems more of an html question than a django specific one … You’ll of course want a post method on the view itself to handle the form.